WO2023284784A1 - 条码图像修复方法、装置、计算机设备和存储介质 - Google Patents

条码图像修复方法、装置、计算机设备和存储介质 Download PDF

Info

Publication number
WO2023284784A1
WO2023284784A1 PCT/CN2022/105453 CN2022105453W WO2023284784A1 WO 2023284784 A1 WO2023284784 A1 WO 2023284784A1 CN 2022105453 W CN2022105453 W CN 2022105453W WO 2023284784 A1 WO2023284784 A1 WO 2023284784A1
Authority
WO
WIPO (PCT)
Prior art keywords
color
barcode image
matrix
target
column
Prior art date
Application number
PCT/CN2022/105453
Other languages
English (en)
French (fr)
Inventor
姚恒志
杨泽同
赵泽林
刘枢
沈小勇
吕江波
Original Assignee
深圳思谋信息科技有限公司
上海思谋科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳思谋信息科技有限公司, 上海思谋科技有限公司 filed Critical 深圳思谋信息科技有限公司
Publication of WO2023284784A1 publication Critical patent/WO2023284784A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/77Retouching; Inpainting; Scratch removal
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20048Transform domain processing
    • G06T2207/20061Hough transform

Definitions

  • the present application relates to the technical field of barcode recognition, in particular to a barcode image restoration method, device, computer equipment and storage medium.
  • Barcode is to arrange several black bars and white bars with different widths according to a certain coding sequence, so as to carry information.
  • a barcode image restoration method, device, computer equipment and storage medium are provided.
  • the application provides a method for repairing a barcode image, including:
  • a target barcode image corresponding to the color matrix is generated.
  • the present application also provides a barcode image restoration device, including:
  • the image response module is used to perform correction processing on the barcode image collected by the terminal device to obtain a corrected barcode image, and the corrected barcode image is a barcode image to be recognized;
  • a matrix generating module configured to identify the color of each pixel in the barcode image to be identified line by line, and generate a color matrix corresponding to the barcode image to be identified according to the color identification result;
  • An identification determination module configured to determine the color identification corresponding to each column of the color matrix according to the number of black elements in each column of the color matrix;
  • An image generating module configured to generate a target barcode image corresponding to the color matrix according to the color identification.
  • the present application also provides a computer device, including a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
  • a target barcode image corresponding to the color matrix is generated.
  • the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • a target barcode image corresponding to the color matrix is generated.
  • the present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the following steps are implemented:
  • a target barcode image corresponding to the color matrix is generated.
  • Fig. 1 is an application environment diagram of a barcode image restoration method in an embodiment.
  • Fig. 2 is a schematic flowchart of a method for repairing a barcode image in an embodiment.
  • Fig. 3 is a schematic flowchart of the step of determining the color identification corresponding to each column of the color matrix in an embodiment.
  • Fig. 4 is a schematic flowchart of the steps of generating a target barcode image corresponding to a color matrix in an embodiment.
  • Fig. 5 is a schematic flowchart of the steps of obtaining the corrected barcode image to be recognized in one embodiment.
  • Fig. 6 is a structural block diagram of a barcode image restoration device in an embodiment.
  • Figure 7 is an internal block diagram of a computer device in one embodiment.
  • the barcode image restoration method provided in this application can be applied to the application environment shown in FIG. 1 .
  • the terminal device 11 communicates with the server 12 through the network.
  • the server 12 corrects the barcode image collected by the terminal device 11 to obtain the corrected barcode image, and the corrected barcode image is the barcode image to be recognized;
  • the server 12 recognizes the color of each pixel in the barcode image to be recognized line by line, according to The color recognition result generates the color matrix corresponding to the barcode image to be recognized;
  • the server 12 determines the corresponding color identification of each column of the color matrix according to the quantity of black elements in each column of the color matrix; the server 12 generates the corresponding color matrix according to the color identification.
  • the corresponding target barcode image is a prefix
  • the terminal 11 can be, but not limited to, various code scanning guns, personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, etc.
  • the server 12 can be implemented by an independent server or a server cluster composed of multiple servers. accomplish.
  • a method for repairing a barcode image is provided, and the application of the method to the server 12 in FIG. 1 is used as an example for illustration, including the following steps:
  • Step 21 Perform correction processing on the barcode image collected by the terminal device to obtain a corrected barcode image, and the corrected barcode image is a barcode image to be recognized.
  • what the terminal device collects may be a barcode image or an image containing a barcode; after the server receives the image sent by the terminal device, it preprocesses the barcode image to obtain a preprocessed barcode image; the server recognizes the barcode
  • the image contains the outline of the barcode, the preprocessed barcode image is subjected to outline extraction processing, the barcode outline of the barcode image is obtained, the barcode is positioned, and the barcode image is obtained.
  • the preprocessing process includes light compensation, noise reduction processing, and binarization processing on the barcode image; for example, you can first use the reverse light compensation method to perform light compensation on the barcode image, and then perform noise reduction processing on the light-compensated barcode image. Then binarize the barcode image after noise reduction, so that the barcode image only contains black barcodes and white background areas.
  • the correction process can be carried out by Hough transform.
  • xcos ⁇ +ysin ⁇ .
  • barcode boundary search for the image space coordinates x and y of each pixel point, use different ⁇ discrete values to calculate the corresponding ⁇ value through the above calculation formula, and obtain the straight line by statistics of ⁇ discrete value and ⁇ value The corresponding pixel coordinates.
  • all the line information in the barcode image can be extracted through the Hough transform, and the barcode image is further corrected according to the inclined angle of the line information.
  • the sample image is rotated and displaced by affine transformation to obtain the corrected image. Rectangular barcode image.
  • the lines corresponding to the barcode are basically perpendicular to the horizontal side of the image of the barcode to be recognized, and the error range of the lines should be within 1 degree.
  • step 22 the color of each pixel in the barcode image to be recognized is recognized line by line, and a color matrix corresponding to the barcode image to be recognized is generated according to the color recognition result.
  • the barcode image to be recognized can be regarded as a rectangle composed of pixels, the height of the barcode image to be recognized is the number of pixels in each column, and the width of the barcode image to be recognized is the number of pixels in each row; the color of the pixel can be determined by The binarization algorithm performs threshold judgment to determine whether the pixel is black or white.
  • the color matrix is a matrix formed by marking the color of each pixel and the position of the pixel; for example, a row of the barcode image to be recognized contains 10 pixels, and the colors are "black-black-black-black-black-black-black- Black-white-white", if the black pixel is marked as 1 and the white pixel is marked as 0, then a row of the corresponding matrix can be "1-1-1-1-1-1-1-0-0".
  • the server scans the barcode image to be recognized line by line to identify the color corresponding to each pixel; when each line is scanned, the corresponding position is marked according to whether the pixel is black, and the recognition result corresponding to the line is obtained, which can be recorded as line; here
  • the number of line elements is the image width; each line of the barcode image to be recognized is scanned, and the lines obtained in each line are saved to obtain RawLines; RawLines can be regarded as a matrix, and its width is the width of the barcode image to be recognized. Its height is the height of the barcode image to be recognized, and each element indicates whether the position is a black pixel.
  • Step 23 according to the number of black elements in each column of the color matrix, determine the color identifier corresponding to each column of the color matrix.
  • the server identifies each column in the color matrix, and determines the number of black elements in each column.
  • the number of black elements reaches a certain condition, it can be considered that the elements in the barcode area occupied by the column should all be black.
  • element, that is to determine the color of the column is black; on the contrary, if the number of black elements does not meet a certain condition, for example, in a column with a height of 100, the number of pixels in the barcode area after removing the numbers below and the blank areas on the upper and lower sides should be 80, and the number of black elements is only 8, it can be determined that the color of the column is white; and 8 black elements can be considered as errors that have not been corrected during the calibration process.
  • Step 24 according to the color identification, generate the target barcode image corresponding to the color matrix.
  • the server can determine the target color of each column in the barcode image to be recognized according to the color identification, so the barcode image can be redrawn according to the color identification combined with the sequence of each column, that is, the number of column elements and the number of row elements in the color matrix can be generated Both correspond to the target barcode image, the height of the target barcode image corresponds to the number of color matrix column elements, and the width corresponds to the number of color matrix row elements.
  • the above barcode image restoration method includes: performing correction processing on the barcode image collected by the terminal equipment to obtain the corrected barcode image, the corrected barcode image is the barcode image to be recognized; identifying each pixel in the barcode image to be recognized line by line Color, generate a color matrix corresponding to the barcode image to be recognized according to the color recognition result; determine the color identification corresponding to each column of the color matrix according to the number of black elements in each column of the color matrix; generate a color matrix corresponding to the color matrix according to the color identification
  • the target barcode image this application generates a color matrix matching the image by performing color recognition on the corrected barcode image to be recognized; the color identification of each column is determined according to the number of black elements in each column in the color matrix, and the color identification is generated according to the color identification
  • the corresponding target barcode image realizes the restoration of the barcode image and improves the efficiency of barcode image recognition.
  • step 23 according to the number of black elements in each column of the color matrix, determines the color identification corresponding to each column of the color matrix, including:
  • Step 31 determine the matrix height of the color matrix according to the number of elements contained in each column of the color matrix
  • Step 32 obtaining the ratio of the number of black elements in the color matrix to the height of the matrix column by column;
  • Step 33 if the ratio is greater than or equal to the preset threshold, then determine the color mark corresponding to the column as black; or,
  • Step 34 if the ratio is smaller than the preset threshold, then determine the color label corresponding to the column as white.
  • the server counts the number of black elements in each column of the color matrix, and obtains the height of the column of the color matrix as a basis for comparison. If the ratio of the number of black elements to the height reaches a certain ratio, it means that the column is dominated by black elements Status, that is, to determine that the barcode of this column is a black barcode, otherwise it is a white background area.
  • the color identification of the column is determined by the ratio of the number of black elements to the height of the matrix; the ratio is obtained column by column and the color identification is determined, which improves the accuracy of color identification determination.
  • step 24 according to the color identification, generates the target barcode image corresponding to the color matrix, including:
  • Step 41 obtaining a target matrix having the same size as the color matrix; wherein, all elements in the target matrix are white elements;
  • Step 42 adjust the color of each element in the target matrix according to the color identification, and obtain the adjusted target matrix
  • Step 43 Generate a target barcode image corresponding to the color matrix according to the adjusted target matrix.
  • the target matrix is a matrix with the same height and width as the color matrix, but the elements in the target matrix are all white.
  • the color of each element in the target matrix is adjusted according to the color identification to obtain the adjusted target matrix, including:
  • the server constructs a matrix with the same size as the target matrix according to the height and width of the color matrix; the server sets the color of the elements in each column corresponding to the target matrix according to the color identification of each column in the color matrix; for example If the 1st, 3rd, 4th, 6th, 7th, and 8th colors in the color matrix are identified as black, all the elements in the 1st, 3rd, 4th, 6th, 7th, and 8th columns in the target matrix are set to black. In this way, the adjustment of the target matrix according to the color matrix is realized. Finally, the server generates the corresponding target barcode image according to the target matrix to complete the restoration of the barcode image.
  • This embodiment provides a basis for generating a target barcode image by constructing a target matrix, and improves the efficiency of generating the target barcode image and the efficiency of recognizing the barcode image.
  • step 21 correction processing is performed on the barcode image collected by the terminal device to obtain a corrected barcode image, including:
  • Step 51 detecting straight lines in the barcode image collected by the terminal device to obtain straight line information; wherein, the straight line information includes angle information of each straight line;
  • Step 52 Perform affine transformation processing on the barcode image collected by the terminal device according to the angle information to obtain a barcode image after affine transformation processing, and the barcode image after affine transformation processing is a corrected barcode image.
  • the server calls the Hough transform algorithm to detect the straight lines in the multi-barcode image, and can determine the pixel coordinates corresponding to the straight lines, as well as the offset information and angle information relative to a certain point; based on the angle information, the barcode to be recognized can be identified The degree of image distortion occurs, and the barcode image is corrected by affine transformation according to the angle information, and the corrected barcode image to be recognized is obtained.
  • the affine transformation process is performed on the barcode image to be recognized through the angle information, so that the barcode image is easier to recognize and operate after correction, and the efficiency of subsequent data processing and barcode image recognition is improved.
  • performing affine transformation processing on the barcode image to be recognized according to the angle information includes: discretizing the angle information to obtain discretized angle information; obtaining the multiplicity angle in the discretization angle information, and the multiplicity angle is Target angle: perform affine transformation processing on the barcode image collected by the terminal device according to the target angle, and obtain the barcode image processed by the affine transformation.
  • the multiplicity angle refers to the angle information that appears most frequently in the discretized angle information, that is, the target angle; the target angle can reflect the degree to which the image needs to be corrected, so the target angle is used to perform radial transformation processing on the barcode image.
  • the corrected barcode image is corrected as much as possible, reducing the error caused in the barcode image restoration process, and improving the barcode image recognition. s efficiency.
  • the target barcode image corresponding to the color matrix according to the color identification after generating the target barcode image corresponding to the color matrix according to the color identification, it also includes:
  • the barcode information in the target barcode image is recognized to obtain a recognition result corresponding to the target barcode image, and the recognition result is the recognition result of the barcode image.
  • the server can directly identify the barcode information in the target barcode image, and obtain the corresponding recognition result.
  • the server directly recognizes the corrected barcode image after correction to obtain a recognition result, which improves the efficiency of barcode image recognition.
  • a barcode image restoration device including: an image response module 61, a matrix generation module 62, an identification determination module 63 and an image generation module 64, wherein:
  • the image response module 61 is used to perform correction processing on the barcode image collected by the terminal device to obtain a corrected barcode image, and the corrected barcode image is a barcode image to be recognized;
  • the matrix generation module 62 is used to recognize the color of each pixel in the barcode image to be recognized row by row, and generates a color matrix corresponding to the barcode image to be recognized according to the color recognition result;
  • Logo determination module 63 for determining the color logo corresponding to each column of the color matrix according to the quantity of black elements in each column of the color matrix
  • the image generation module 64 is configured to generate a target barcode image corresponding to the color matrix according to the color identification.
  • the identification determination module 63 is also used to determine the matrix height of the color matrix according to the number of elements contained in each column of the color matrix; obtain the ratio of the number of black elements in the color matrix to the height of the matrix column by column; if If the ratio is greater than or equal to the preset threshold, the color identifier corresponding to the column is determined to be black; or, if the ratio is smaller than the preset threshold, the color identifier corresponding to the column is determined to be white.
  • the image generation module 64 is also used to obtain a target matrix with the same size as the color matrix; wherein, all elements in the target matrix are white elements; adjust the color of each element in the target matrix according to the color identification to obtain the adjusted The adjusted target matrix; according to the adjusted target matrix, a target barcode image corresponding to the color matrix is generated.
  • the image generation module 64 is further configured to identify the column whose color is marked as black in the color matrix, and the column whose color is marked as black in the color matrix is the target column; the column corresponding to the target column in the target matrix The colors of all elements are set to black to obtain the adjusted target matrix.
  • the image response module 61 is also used to detect the straight line in the barcode image collected by the terminal device to obtain the straight line information; wherein, the straight line information includes the angle information of each straight line;
  • the barcode image is subjected to affine transformation processing to obtain a barcode image after affine transformation processing, and the barcode image after affine transformation processing is a barcode image after correction processing.
  • the image response module 61 is also used to discretize the angle information to obtain discretized angle information; obtain the multiplicity angle in the discretized angle information, and the multiplicity angle is the target angle;
  • the barcode image collected by the terminal device is subjected to affine transformation processing to obtain the barcode image processed by the affine transformation.
  • the image response module is also used to obtain the number of occurrences of each angle information in the discretized angle information; determine the angle information with the largest number of occurrences from the discretized angle information, and the angle information with the largest number of occurrences is the multiplicity angle .
  • the barcode image restoration device further includes a barcode recognition module for recognizing barcode information in the target barcode image and obtaining a recognition result corresponding to the target barcode image, the recognition result being the recognition result of the barcode image.
  • the image response module is also used to preprocess the barcode image collected by the terminal device to obtain the preprocessed barcode image; wherein the preprocessing includes light compensation, noise reduction processing and binarization processing; The preprocessed barcode image is corrected to obtain the corrected barcode image.
  • Each module in the above-mentioned barcode image repairing device can be fully or partially realized by software, hardware and combinations thereof.
  • the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.
  • a computer device which may be a server, in which
  • the internal structure diagram can be shown in Figure 7.
  • the computer device includes a processor, memory and a network interface connected by a system bus. Wherein, the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer programs and databases.
  • the internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer device is used for storing barcode image repair data.
  • the network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a barcode image restoration method is realized.
  • FIG. 7 is only a block diagram of a part of the structure related to the solution of this application, and does not constitute a limitation to the computer equipment on which the solution of this application is applied.
  • the specific computer equipment can be More or fewer components than shown in the figures may be included, or some components may be combined, or have a different arrangement of components.
  • a computer device including a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
  • a target barcode image corresponding to the color matrix is generated.
  • the following steps are also implemented when the processor executes the computer program: determine the matrix height of the color matrix according to the number of elements contained in each column of the color matrix; obtain the ratio of the number of black elements in the color matrix to the height of the matrix column by column Ratio; if the ratio is greater than or equal to the preset threshold, the color identifier corresponding to the column is determined to be black; or, if the ratio is smaller than the preset threshold, the color identifier corresponding to the column is determined to be white.
  • the processor when the processor executes the computer program, the following steps are also implemented: obtaining a target matrix having the same size as the color matrix; wherein, all elements in the target matrix are white elements; adjusting the color of each element in the target matrix according to the color identification , to obtain the adjusted target matrix; according to the adjusted target matrix, a target barcode image corresponding to the color matrix is generated.
  • the processor when the processor executes the computer program, the following steps are also implemented: identifying the column whose color is marked as black in the color matrix, and the column whose color is marked as black in the color matrix is the target column; corresponding to the target column in the target matrix The color of all the elements of the column of is set to black, and the adjusted target matrix is obtained.
  • the processor executes the computer program, the following steps are also implemented: detecting the straight line in the barcode image collected by the terminal device to obtain the straight line information; wherein, the straight line information includes the angle information of each straight line;
  • the collected barcode image is subjected to affine transformation processing to obtain a barcode image after affine transformation processing, and the barcode image after affine transformation processing is a corrected barcode image.
  • the following steps are also implemented when the processor executes the computer program: discretize the angle information to obtain discretized angle information; obtain the multiplicity angle in the discretized angle information, and the multiplicity angle is the target angle;
  • the target angle performs affine transformation processing on the barcode image collected by the terminal device to obtain the barcode image processed by the affine transformation.
  • the processor executes the computer program, the following steps are further implemented: identifying the barcode information in the target barcode image, obtaining a recognition result corresponding to the target barcode image, and the recognition result is the recognition result of the barcode image.
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • a target barcode image corresponding to the color matrix is generated.
  • the following steps are also implemented: determining the matrix height of the color matrix according to the number of elements contained in each column of the color matrix; obtaining the number and matrix height of the black elements in the color matrix column by column ; if the ratio is greater than or equal to the preset threshold, the color identifier corresponding to the column is determined to be black; or, if the ratio is smaller than the preset threshold, the color identifier corresponding to the column is determined to be white.
  • the following steps are also implemented: obtaining a target matrix having the same size as the color matrix; wherein, all elements in the target matrix are white elements; adjusting the color of each element in the target matrix according to the color identification color to obtain an adjusted target matrix; according to the adjusted target matrix, a target barcode image corresponding to the color matrix is generated.
  • the following steps are also implemented: identifying the column whose color is marked as black in the color matrix, and the column whose color is identified as black in the color matrix is the target column; The colors of all the elements in the corresponding columns are set to black to obtain the adjusted target matrix.
  • the following steps are also implemented: detecting the straight line in the barcode image collected by the terminal device to obtain the straight line information; wherein, the straight line information includes the angle information of each straight line;
  • the barcode image collected by the equipment is processed by affine transformation to obtain the barcode image after the affine transformation processing, and the barcode image after the affine transformation processing is the corrected barcode image.
  • the following steps are further implemented: performing discretization processing on the angle information to obtain discretized angle information; obtaining the multiplicity angle in the discretized angle information, where the multiplicity angle is the target angle; Affine transformation processing is performed on the barcode image collected by the terminal device according to the target angle to obtain the barcode image processed by the affine transformation.
  • the following steps are further implemented: identifying barcode information in the target barcode image, obtaining a recognition result corresponding to the target barcode image, and the recognition result is the recognition result of the barcode image.
  • any references to memory, storage, database or other media used in the various embodiments provided in the present application may include at least one of non-volatile memory and volatile memory.
  • Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory or optical memory, etc.
  • Volatile memory can include Random Access Memory (RAM) or external cache memory.
  • RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Quality & Reliability (AREA)
  • Image Processing (AREA)

Abstract

本申请涉及一种条码图像修复方法、装置、计算机设备和存储介质,包括:对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,校正处理后的条码图像为待识别条码图像(21);逐行识别待识别条码图像中各个像素的颜色,根据颜色识别结果生成与待识别条码图像对应的颜色矩阵(22);根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应的颜色标识(23);根据颜色标识,生成与颜色矩阵对应的目标条码图像(24)。

Description

条码图像修复方法、装置、计算机设备和存储介质
本申请要求于2021年07月16日提交中国专利局,申请号为2021108076992,申请名称为“条码图像修复方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及条码识别技术领域,特别是涉及一种条码图像修复方法、装置、计算机设备和存储介质。
背景技术
条形码(barcode)是将宽度不等若干黑条和白条,按照一定的编码顺序排列,以便携带信息。
然而,由于印刷质量、成像反光、条码磨损等情况,会导致条码中部分内容不可获取,导致条码无法被识别,影响条码图像的识别效率;因此,还需要一种条码图像修复方法,以提高条码图像识别的效率。
发明内容
根据本申请公开的各种实施例,提供一种条码图像修复方法、装置、计算机设备和存储介质。
第一方面,本申请提供了一种条码图像修复方法,包括:
对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,所述校正处理后的条码图像为待识别条码图像;
逐行识别所述待识别条码图像中各个像素的颜色,根据颜色识别结果生成与所述待识别条码图像对应的颜色矩阵;
根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识;
根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像。
第二方面,本申请还提供了一种条码图像修复装置,包括:
图像响应模块,用于对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,所述校正处理后的条码图像为待识别条码图像;
矩阵生成模块,用于逐行识别所述待识别条码图像中各个像素的颜色,根据颜色识别结果生成与所述待识别条码图像对应的颜色矩阵;
标识确定模块,用于根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识;
图像生成模块,用于根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像。
第三方面,本申请还提供了一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现以下步骤:
对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,所述校正处理后的条码图像为待识别条码图像;
逐行识别所述待识别条码图像中各个像素的颜色,根据颜色识别结果生成与所述待识别条码图像对应的颜色矩阵;
根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识;
根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像。
第四方面,本申请还提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以下步骤:
对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,所述校正处理后的条码图像为待识别条码图像;
逐行识别所述待识别条码图像中各个像素的颜色,根据颜色识别结果生成与所述待识别条码图像对应的颜色矩阵;
根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识;
根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像。
第五方面,本申请还提供了一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现以下步骤:
对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,所述校正处理后的条码图像为待识别条码图像;
逐行识别所述待识别条码图像中各个像素的颜色,根据颜色识别结果生成与所述待识别条码图像对应的颜色矩阵;
根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识;
根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更好地描述和说明这里公开的那些发明的实施例和示例,可以参考一幅或多幅附图。用于描述附图的附加细书或示例不应当被认为是对所公开的发明、目前描述的实施例和示例以及目前理解的这些发明的最佳模式中的任何一者的范围的限制。
图1为一个实施例中条码图像修复方法的应用环境图。
图2为一个实施例中条码图像修复方法的流程示意图。
图3为一个实施例中确定颜色矩阵的各个列所对应的颜色标识步骤的流程示意图。
图4为一个实施例中生成与颜色矩阵对应的目标条码图像步骤的流程示意图。
图5为一个实施例中得到校正处理后的待识别条码图像步骤的流程示意图。
图6为一个实施例中条码图像修复装置的结构框图。
图7为一个实施例中计算机设备的内部结构图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请提供的条码图像修复方法,可以应用于如图1所示的应用环境中。其中,终端设备11通过网络与服务器12进行通信。服务器12对终端设备11采集的条码图像进行校正处理,得到校正处理后的条码图像,校正处理后的条码图像为待识别条码图像;服务器12逐行识别待识别条码图像中各个像素的颜色,根据颜色识别结果生成与待识别条码图像对应的颜色矩阵;服务器12根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应的颜色标识;服务器12根据颜色标识,生成与颜色矩阵对应的目标条码图像。
其中,终端11可以但不限于是各种扫码枪、个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备等,服务器12可以用独立的服务器或者是多个服务器组成的服务器集群来实现。
在一个些实施例中,如图2所示,提供了一种条码图像修复方法,以该方法应用于图1中的服务器12为例进行说明,包括以下步骤:
步骤21,对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,校正处理后的条码图像为待识别条码图像。
具体地,终端设备采集到的可以是条码图像,也可以是包含有条码的图像;服务器接收到终端设备发送的图像后,对条码图像进行预处理,得到预处理后的条码图像;服务器识别条码图像中包含有条码的轮廓,对预处理后的条码图像进行轮廓提取处理,获取条码图像的条码轮廓,对条码进行定位,并获取条码图像。
预处理过程包括对条码图像进行光线补偿、降噪处理、二值化处理等;例如,可以首先采用逆向光线补偿方法对条码图像进行光线补偿,然后对光线补偿后的条码图像进行降噪处理,再对降噪后的条码图像进行二值化处理,使得条码图像中仅包含黑色的条码以及白色的背景区域。
校正处理可以通过霍夫变换进行,霍夫变换的原理是:假设在直角坐标系中存在一条原点距离为ρ,方位角为θ的直线,则直线上每一点满足公式ρ= xcosθ+ysinθ。在条码边界搜索过程中,对于每一个像素点的图像空间坐标x、y,利用不同的θ离散值通过上述运算公式计算对应的ρ值,通过对θ离散值和ρ值的统计,求得直线所对应的像素坐标。
即通过霍夫变换能够提取出条码图像中所有的线条信息,进一步根据线条信息倾斜的角度对条码图像进行矫正,例如通过仿射变换方式对样本图像进行旋转、位移等处理,得到校正处理后的呈矩形的条码图像。并且,校正处理后的待识别条码图像中,条码对应的线条基本垂直于待识别条码图像的横边,且线条的误差范围应在1度之内。
步骤22,逐行识别待识别条码图像中各个像素的颜色,根据颜色识别结果生成与待识别条码图像对应的颜色矩阵。
其中,待识别条码图像可以看作是一个由像素组成的矩形,待识别条码图像的高度即为每一列像素的数量,待识别条码图像的宽度即为每一行像素的数量;像素的颜色可以通过二值化算法进行阈值判断,以确定出像素为黑色或者白色。
颜色矩阵是对各个像素的颜色,对像素所在位置进行标记后形成的矩阵;例如待识别条码图像的某一行包含有10个像素,颜色分别为“黑-黑-黑-黑-黑-黑-黑-白-白”,若将黑色像素标记为1,白色像素标记为0,则对应矩阵的一行可以为“1-1-1-1-1-1-1-0-0”。
具体地,服务器对待识别条码图像进行逐行扫描,识别各个像素对应的颜色;每一行扫描时按照像素是否为黑色对相应位置进行标识,得到与该行对应的识别结果,可以记为line;这里line的元素个数即为图像宽度;对待识别条码图像的每一行都进行扫描,将每一行得到的line都进行保存得到RawLines;RawLines可以视为一个矩阵,其宽度为待识别条码图像的宽度,其高度为待识别条码图像的高度,其中每一个元素表征该位置是否为黑色像素。
步骤23,根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应的颜色标识。
具体地,服务器对颜色矩阵中各个列进行识别,确定出各个列中黑色元素的数量,当黑色元素的数量达到一定条件后即可认为该列中所占有的条码区域 中的元素应全部为黑色元素,即确定该列的颜色标识为黑色;反之,若黑色元素的数量未达到一定条件,例如高度100的列中,除去下方数字和上下两侧的留白区域后条码区域的像素数量应为80,而其中黑色元素的数量仅为8,则可确定该列的颜色标识为白色;而8个黑色元素可认为是校正过程中未校正过来而存在的误差。
步骤24,根据颜色标识,生成与颜色矩阵对应的目标条码图像。
具体地,服务器根据颜色标识可以确定出待识别条码图像中各列的目标颜色,因此可以根据颜色标识结合各列的前后次序等重新绘制条码图像,即生成与颜色矩阵列元素数量与行元素数量均对应的目标条码图像,目标条码图像的高度与颜色矩阵列元素数量对应,宽度与颜色矩阵行元素数量均对应。
上述条码图像修复方法,包括:对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,校正处理后的条码图像为待识别条码图像;逐行识别待识别条码图像中各个像素的颜色,根据颜色识别结果生成与待识别条码图像对应的颜色矩阵;根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应的颜色标识;根据颜色标识,生成与颜色矩阵对应的目标条码图像;本申请通过对校正后的待识别条码图像进行颜色识别,生成与该图像匹配的颜色矩阵;根据颜色矩阵中各列的黑色元素数量确定各列的颜色标识,根据颜色标识生成对应的目标条码图像,实现对条码图像的修复,提高了提高条码图像识别的效率。
在一些实施例中,如图3所示,步骤23,根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应的颜色标识,包括:
步骤31,根据颜色矩阵的各个列所包含的元素数量,确定颜色矩阵的矩阵高度;
步骤32,逐列获取颜色矩阵中黑色元素的数量与矩阵高度的比值;
步骤33,若比值大于或等于预设阈值,则将该列所对应的颜色标识确定为黑色;或者,
步骤34,若比值小于预设阈值,则将该列所对应的颜色标识确定为白色。
具体地,服务器对颜色矩阵中每一列黑色元素的数量进行统计,并获取颜 色矩阵的列的高度作为比较依据,若黑色元素的数量与高度的比值达到一定比例,说明该列为黑色元素占主导地位,即确定该列的条码为黑色条码,反之则为白色背景区域。
本实施例中,通过黑色元素的数量与矩阵高度的比值,对列的颜色标识进行确定;逐列获取比值并判断颜色标识,提高了颜色标识确定的准确度。
在一些实施例中,如图4所示,步骤24,根据颜色标识,生成与颜色矩阵对应的目标条码图像,包括:
步骤41,获取与颜色矩阵大小相同的目标矩阵;其中,目标矩阵中所有元素均为白色元素;
步骤42,根据颜色标识调整目标矩阵中各个元素的颜色,得到调整后的目标矩阵;
步骤43,根据调整后的目标矩阵,生成与颜色矩阵对应的目标条码图像。
其中,目标矩阵是与颜色矩阵高度、宽度均相同的矩阵,但目标矩阵中的元素均为白色。
在一些实施例中,根据颜色标识调整目标矩阵中各个元素的颜色,得到调整后的目标矩阵,包括:
识别出颜色矩阵中颜色标识为黑色的列,颜色矩阵中颜色标识为黑色的列为目标列;
将目标矩阵中与目标列对应的列的全部元素的颜色均设置为黑色,得到调整后的目标矩阵。
具体地,服务器根据颜色矩阵的高度、宽度等构件一个尺寸大小相同的矩阵作为目标矩阵;服务器根据颜色矩阵中各个列的颜色标识,对目标矩阵对应的各个列中元素的颜色进行设定;例如颜色矩阵中第1、3、4、6、7、8的颜色标识为黑色,则将目标矩阵中第1、3、4、6、7、8列中所有元素均设置为黑色。以此实现根据颜色矩阵对目标矩阵的调整。最后,服务器根据目标矩阵生成对应的目标条码图像即完成对条码图像的修复。
本实施例通过构建目标矩阵,为生成目标条码图像提供了基础,提高了目标条码图像生成的效率,以及对条码图像进行识别的效率。
在一些实施例中,如图5所示,步骤21,对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,包括:
步骤51,检测终端设备采集的条码图像中的直线,得到直线信息;其中,直线信息包含有各个直线的角度信息;
步骤52,根据角度信息对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像,仿射变换处理后的条码图像为校正处理后的条码图像。
具体地,服务器调用霍夫变换算法对多条码图像中的直线进行检测,能够确定出直线所对应的像素坐标,以及相对一定点的偏移信息和角度信息;基于角度信息能够识别出待识别条码图像发生畸变的程度,并根据角度信息利用仿射变换对条码图像进行校正处理,得到校正处理后的待识别条码图像。
本实施例通过角度信息对待识别条码图像进行仿射变换处理,使得条码图像经过校正更易于识别运算,提高了后续数据处理以及条码图像识别的效率。
在一些实施例中,根据角度信息对待识别条码图像进行仿射变换处理,包括:对角度信息进行离散化处理,得到离散化角度信息;获取离散化角度信息中的重数角度,重数角度为目标角度;根据目标角度对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像。
具体地,重数角度是指离散化后的角度信息中出现次数最多的角度信息,即目标角度;目标角度能够反映出图像需要矫正的程度,因此采用目标角度对条码图像进行放射变换处理。
本实施例通过将重数角度作为目标角度,并对待识别条码图像进行仿射变换,使得校正后的条码图像尽可能地被校正,减少条码图像修复过程中带来的误差,提高了条码图像识别的效率。
在一些实施例中,根据颜色标识,生成与颜色矩阵对应的目标条码图像之后,还包括:
识别目标条码图像中的条码信息,得到与目标条码图像对应的识别结果,识别结果为条码图像的识别结果。
具体地,目标条码图像中的条码信息已经补全,因此服务器能够直接对目 标条码图像中的条码信息进行识别,得到相应识别结果。
本实施例中服务器在校正后直接对校正后的条码图像进行识别,得到识别结果,提高了条码图像识别的效率。
应该理解的是,虽然图2-5的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-5中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。
在一些实施例中,如图6所示,提供了一种条码图像修复装置,包括:图像响应模块61、矩阵生成模块62、标识确定模块63及图像生成模块64,其中:
图像响应模块61,用于对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,校正处理后的条码图像为待识别条码图像;
矩阵生成模块62,用于逐行识别待识别条码图像中各个像素的颜色,根据颜色识别结果生成与待识别条码图像对应的颜色矩阵;
标识确定模块63,用于根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应的颜色标识;
图像生成模块64,用于根据颜色标识,生成与颜色矩阵对应的目标条码图像。
在一些实施例中,标识确定模块63,还用于根据颜色矩阵的各个列所包含的元素数量,确定颜色矩阵的矩阵高度;逐列获取颜色矩阵中黑色元素的数量与矩阵高度的比值;若比值大于或等于预设阈值,则将该列所对应的颜色标识确定为黑色;或者,若比值小于预设阈值,则将该列所对应的颜色标识确定为白色。
在一些实施例中,图像生成模块64,还用于获取与颜色矩阵大小相同的目标矩阵;其中,目标矩阵中所有元素均为白色元素;根据颜色标识调整目标矩 阵中各个元素的颜色,得到调整后的目标矩阵;根据调整后的目标矩阵,生成与颜色矩阵对应的目标条码图像。
在一些实施例中,图像生成模块64,还用于识别出颜色矩阵中颜色标识为黑色的列,颜色矩阵中颜色标识为黑色的列为目标列;将目标矩阵中与目标列对应的列的全部元素的颜色均设置为黑色,得到调整后的目标矩阵。
在一些实施例中,图像响应模块61,还用于检测终端设备采集的条码图像中的直线,得到直线信息;其中,直线信息中包含有各个直线的角度信息;根据角度信息对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像,仿射变换处理后的条码图像为校正处理后的条码图像。
在一些实施例中,图像响应模块61,还用于对角度信息进行离散化处理,得到离散化角度信息;获取离散化角度信息中的重数角度,重数角度为目标角度;根据目标角度对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像。
在一些实施例中,图像响应模块,还用于获取离散化角度信息中各个角度信息的出现次数;从离散化角度信息中确定出现次数最多的角度信息,出现次数最多的角度信息为重数角度。
在一些实施例中,条码图像修复装置中还包括条码识别模块,用于识别目标条码图像中的条码信息,得到与目标条码图像对应的识别结果,识别结果为条码图像的识别结果。
在一些实施例中,图像响应模块,还用于对终端设备采集的条码图像进行预处理,得到预处理后的条码图像;其中,预处理包括光线补偿、降噪处理和二值化处理;对预处理后的条码图像进行校正处理,得到校正处理后的条码图像。
关于条码图像修复装置的具体限定可以参见上文中对于条码图像修复方法的限定,在此不再赘述。上述条码图像修复装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一些实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内
部结构图可以如图7所示。该计算机设备包括通过系统总线连接的处理器、存储器和网络接口。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储条码图像修复数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种条码图像修复方法。
本领域技术人员可以理解,图7中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
在一些实施例中,提供了一种计算机设备,包括存储器和处理器,存储器中存储有计算机程序,该处理器执行计算机程序时实现以下步骤:
对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,校正处理后的条码图像为待识别条码图像;
逐行识别待识别条码图像中各个像素的颜色,根据颜色识别结果生成与待识别条码图像对应的颜色矩阵;
根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应的颜色标识;
根据颜色标识,生成与颜色矩阵对应的目标条码图像。
在一些实施例中,处理器执行计算机程序时还实现以下步骤:根据颜色矩阵的各个列所包含的元素数量,确定颜色矩阵的矩阵高度;逐列获取颜色矩阵中黑色元素的数量与矩阵高度的比值;若比值大于或等于预设阈值,则将该列所对应的颜色标识确定为黑色;或者,若比值小于预设阈值,则将该列所对应的颜色标识确定为白色。
在一些实施例中,处理器执行计算机程序时还实现以下步骤:获取与颜色矩阵大小相同的目标矩阵;其中,目标矩阵中所有元素均为白色元素;根据颜色标识调整目标矩阵中各个元素的颜色,得到调整后的目标矩阵;根据调整后的目标矩阵,生成与颜色矩阵对应的目标条码图像。
在一些实施例中,处理器执行计算机程序时还实现以下步骤:识别出颜色矩阵中颜色标识为黑色的列,颜色矩阵中颜色标识为黑色的列为目标列;将目标矩阵中与目标列对应的列的全部元素的颜色均设置为黑色,得到调整后的目标矩阵。
在一些实施例中,处理器执行计算机程序时还实现以下步骤:检测终端设备采集的条码图像中的直线,得到直线信息;其中,直线信息包含有各个直线的角度信息;根据角度信息对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像,仿射变换处理后的条码图像为校正处理后的条码图像。
在一些实施例中,处理器执行计算机程序时还实现以下步骤:对角度信息进行离散化处理,得到离散化角度信息;获取离散化角度信息中的重数角度,重数角度为目标角度;根据目标角度对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像。
在一些实施例中,处理器执行计算机程序时还实现以下步骤:识别目标条码图像中的条码信息,得到与目标条码图像对应的识别结果,识别结果为条码图像的识别结果。
在一些实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:
对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,校正处理后的条码图像为待识别条码图像;
逐行识别待识别条码图像中各个像素的颜色,根据颜色识别结果生成与待识别条码图像对应的颜色矩阵;
根据颜色矩阵的各个列中黑色元素的数量,确定颜色矩阵的各个列所对应 的颜色标识;
根据颜色标识,生成与颜色矩阵对应的目标条码图像。
在一些实施例中,计算机程序被处理器执行时还实现以下步骤:根据颜色矩阵的各个列所包含的元素数量,确定颜色矩阵的矩阵高度;逐列获取颜色矩阵中黑色元素的数量与矩阵高度的比值;若比值大于或等于预设阈值,则将该列所对应的颜色标识确定为黑色;或者,若比值小于预设阈值,则将该列所对应的颜色标识确定为白色。
在一些实施例中,计算机程序被处理器执行时还实现以下步骤:获取与颜色矩阵大小相同的目标矩阵;其中,目标矩阵中所有元素均为白色元素;根据颜色标识调整目标矩阵中各个元素的颜色,得到调整后的目标矩阵;根据调整后的目标矩阵,生成与颜色矩阵对应的目标条码图像。
在一些实施例中,计算机程序被处理器执行时还实现以下步骤:识别出颜色矩阵中颜色标识为黑色的列,颜色矩阵中颜色标识为黑色的列为目标列;将目标矩阵中与目标列对应的列的全部元素的颜色均设置为黑色,得到调整后的目标矩阵。
在一些实施例中,计算机程序被处理器执行时还实现以下步骤:检测终端设备采集的条码图像中的直线,得到直线信息;其中,直线信息包含有各个直线的角度信息;根据角度信息对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像,仿射变换处理后的条码图像为校正处理后的条码图像。
在一些实施例中,计算机程序被处理器执行时还实现以下步骤:对角度信息进行离散化处理,得到离散化角度信息;获取离散化角度信息中的重数角度,重数角度为目标角度;根据目标角度对终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像。
在一些实施例中,计算机程序被处理器执行时还实现以下步骤:识别目标条码图像中的条码信息,得到与目标条码图像对应的识别结果,识别结果为条码图像的识别结果。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,上述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。非易失性存储器可包括只读存储器(Read-Only Memory,ROM)、磁带、软盘、闪存或光存储器等。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或外部高速缓冲存储器。作为说明而非局限,RAM可以是多种形式,比如静态随机存取存储器(Static Random Access Memory,SRAM)或动态随机存取存储器(Dynamic Random Access Memory,DRAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上各个实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (20)

  1. 一种条码图像修复方法,其特征在于,包括:
    对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,所述校正处理后的条码图像为待识别条码图像;
    逐行识别所述待识别条码图像中各个像素的颜色,根据颜色识别结果生成与所述待识别条码图像对应的颜色矩阵;
    根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识;
    根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识,包括:
    根据所述颜色矩阵的各个列所包含的元素数量,确定所述颜色矩阵的矩阵高度;
    逐列获取所述颜色矩阵中黑色元素的数量与所述矩阵高度的比值;
    若所述比值大于或等于预设阈值,则将该列所对应的颜色标识确定为黑色;或者,
    若所述比值小于所述预设阈值,则将该列所对应的颜色标识确定为白色。
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像,包括:
    获取与所述颜色矩阵大小相同的目标矩阵;其中,所述目标矩阵中所有元素均为白色元素;
    根据所述颜色标识调整所述目标矩阵中各个元素的颜色,得到调整后的目标矩阵;
    根据所述调整后的目标矩阵,生成与所述颜色矩阵对应的目标条码图像。
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述颜色标识调整所述目标矩阵中各个元素的颜色,得到调整后的目标矩阵,包括:
    识别出所述颜色矩阵中所述颜色标识为黑色的列,所述颜色矩阵中所述颜色标识为黑色的列为目标列;
    将所述目标矩阵中与所述目标列对应的列的全部元素的颜色均设置为黑色,得到调整后的目标矩阵。
  5. 根据权利要求1所述的方法,其特征在于,所述对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,包括:
    检测终端设备采集的条码图像中的直线,得到直线信息;其中,所述直线信息包含有各个直线的角度信息;
    根据所述角度信息对所述终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像,所述仿射变换处理后的条码图像为校正处理后的条码图像。
  6. 根据权利要求5所述的方法,其特征在于,所述根据所述角度信息对所述终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像,包括:
    对所述角度信息进行离散化处理,得到离散化角度信息;
    获取所述离散化角度信息中的重数角度,所述重数角度为目标角度;
    根据所述目标角度对所述终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像。
  7. 根据权利要求6所述的方法,其特征在于,所述获取所述离散化角度信息中的重数角度,包括:
    获取所述离散化角度信息中各个角度信息的出现次数;
    从所述离散化角度信息中确定出现次数最多的角度信息,所述出现次数最多的角度信息为重数角度。
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像之后,还包括:
    识别所述目标条码图像中的条码信息,得到与所述目标条码图像对应的识别结果,所述识别结果为所述条码图像的识别结果。
  9. 根据权利要求1所述的方法,其特征在于,所述对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,包括:
    对终端设备采集的条码图像进行预处理,得到预处理后的条码图像;其中, 所述预处理包括光线补偿、降噪处理和二值化处理;
    对所述预处理后的条码图像进行校正处理,得到校正处理后的条码图像。
  10. 一种条码图像修复装置,其特征在于,包括:
    图像响应模块,用于对终端设备采集的条码图像进行校正处理,得到校正处理后的条码图像,所述校正处理后的条码图像为待识别条码图像;
    矩阵生成模块,用于逐行识别所述待识别条码图像中各个像素的颜色,根据颜色识别结果生成与所述待识别条码图像对应的颜色矩阵;
    标识确定模块,用于根据所述颜色矩阵的各个列中黑色元素的数量,确定所述颜色矩阵的各个列所对应的颜色标识;
    图像生成模块,用于根据所述颜色标识,生成与所述颜色矩阵对应的目标条码图像。
  11. 根据权利要求10所述的装置,其特征在于,所述标识确定模块,还用于根据所述颜色矩阵的各个列所包含的元素数量,确定所述颜色矩阵的矩阵高度;逐列获取所述颜色矩阵中黑色元素的数量与所述矩阵高度的比值;若所述比值大于或等于预设阈值,则将该列所对应的颜色标识确定为黑色;或者,若所述比值小于所述预设阈值,则将该列所对应的颜色标识确定为白色。
  12. 根据权利要求11所述的装置,其特征在于,所述图像生成模块,还用于获取与所述颜色矩阵大小相同的目标矩阵;其中,所述目标矩阵中所有元素均为白色元素;根据所述颜色标识调整所述目标矩阵中各个元素的颜色,得到调整后的目标矩阵;根据所述调整后的目标矩阵,生成与所述颜色矩阵对应的目标条码图像。
  13. 根据权利要求12所述的装置,其特征在于,所述图像生成模块,还用于识别出所述颜色矩阵中所述颜色标识为黑色的列,所述颜色矩阵中所述颜色标识为黑色的列为目标列;将所述目标矩阵中与所述目标列对应的列的全部元素的颜色均设置为黑色,得到调整后的目标矩阵。
  14. 根据权利要求10所述的装置,其特征在于,所述图像响应模块,还用于检测终端设备采集的条码图像中的直线,得到直线信息;其中,所述直线信息中包含有各个直线的角度信息;根据所述角度信息对所述终端设备采集的条 码图像进行仿射变换处理,得到仿射变换处理后的条码图像,所述仿射变换处理后的条码图像为校正处理后的条码图像。
  15. 根据权利要求14所述的装置,其特征在于,所述图像响应模块,还用于对所述角度信息进行离散化处理,得到离散化角度信息;获取所述离散化角度信息中的重数角度,所述重数角度为目标角度;根据所述目标角度对所述终端设备采集的条码图像进行仿射变换处理,得到仿射变换处理后的条码图像。
  16. 根据权利要求15所述的装置,其特征在于,所述图像响应模块,还用于获取所述离散化角度信息中各个角度信息的出现次数;从所述离散化角度信息中确定出现次数最多的角度信息,所述出现次数最多的角度信息为重数角度。
  17. 根据权利要求10-16任一项所述的装置,其特征在于,所述装置还包括条码识别模块,用于识别所述目标条码图像中的条码信息,得到与所述目标条码图像对应的识别结果,所述识别结果为所述条码图像的识别结果。
  18. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,其特征在于,所述处理器执行所述计算机程序时实现权利要求1至9中任一项所述的方法的步骤。
  19. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1至9中任一项所述的方法的步骤。
  20. 一种计算机程序产品,包括计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1-9中任一项所述的方法的步骤。
PCT/CN2022/105453 2021-07-16 2022-07-13 条码图像修复方法、装置、计算机设备和存储介质 WO2023284784A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110807699.2A CN113449536B (zh) 2021-07-16 2021-07-16 条码图像修复方法、装置、计算机设备和存储介质
CN202110807699.2 2021-07-16

Publications (1)

Publication Number Publication Date
WO2023284784A1 true WO2023284784A1 (zh) 2023-01-19

Family

ID=77816536

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/105453 WO2023284784A1 (zh) 2021-07-16 2022-07-13 条码图像修复方法、装置、计算机设备和存储介质

Country Status (2)

Country Link
CN (1) CN113449536B (zh)
WO (1) WO2023284784A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113449536B (zh) * 2021-07-16 2023-02-14 深圳思谋信息科技有限公司 条码图像修复方法、装置、计算机设备和存储介质
CN114239635B (zh) * 2021-12-22 2024-02-02 支付宝(杭州)信息技术有限公司 一种针对doi图像涂鸦的处理方法、装置及设备
CN114943241B (zh) * 2022-07-26 2022-10-25 北京紫光青藤微系统有限公司 用于修复条码码图的方法、电子设备、存储介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008075898A1 (en) * 2006-12-20 2008-06-26 Ji Deak Cheon Method and the algorithm to transform '1d & 2d black and white barcode' to color code
CN102136058A (zh) * 2011-04-26 2011-07-27 中国农业大学 条形码图像识别方法
US9454688B1 (en) * 2015-07-20 2016-09-27 Konica Minolta Laboratory U.S.A., Inc. High capacity 2D color barcode design and decoding method
CN106446751A (zh) * 2016-10-11 2017-02-22 福建中金在线信息科技有限公司 一种条形码识别方法及装置
CN109214229A (zh) * 2017-06-30 2019-01-15 杭州海康威视数字技术股份有限公司 一种条码扫描方法、装置及电子设备
CN111311497A (zh) * 2020-02-12 2020-06-19 广东工业大学 一种条形码图像角度校正方法和装置
CN113449536A (zh) * 2021-07-16 2021-09-28 深圳思谋信息科技有限公司 条码图像修复方法、装置、计算机设备和存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000353211A (ja) * 1999-06-09 2000-12-19 Mitsubishi Electric Corp バーコード認識装置及びバーコード認識方法
CN111008540B (zh) * 2019-11-29 2021-10-22 联想(北京)有限公司 一种条码识别方法及设备、计算机存储介质
CN111339797B (zh) * 2020-02-25 2023-05-02 福州符号信息科技有限公司 一种能够准确识别受损一维条码的解码方法及终端
CN112434543B (zh) * 2020-11-24 2022-02-01 山东大学 一种针对畸变彩色直接部件标记的图像重构方法及系统

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008075898A1 (en) * 2006-12-20 2008-06-26 Ji Deak Cheon Method and the algorithm to transform '1d & 2d black and white barcode' to color code
CN102136058A (zh) * 2011-04-26 2011-07-27 中国农业大学 条形码图像识别方法
US9454688B1 (en) * 2015-07-20 2016-09-27 Konica Minolta Laboratory U.S.A., Inc. High capacity 2D color barcode design and decoding method
CN106446751A (zh) * 2016-10-11 2017-02-22 福建中金在线信息科技有限公司 一种条形码识别方法及装置
CN109214229A (zh) * 2017-06-30 2019-01-15 杭州海康威视数字技术股份有限公司 一种条码扫描方法、装置及电子设备
CN111311497A (zh) * 2020-02-12 2020-06-19 广东工业大学 一种条形码图像角度校正方法和装置
CN113449536A (zh) * 2021-07-16 2021-09-28 深圳思谋信息科技有限公司 条码图像修复方法、装置、计算机设备和存储介质

Also Published As

Publication number Publication date
CN113449536B (zh) 2023-02-14
CN113449536A (zh) 2021-09-28

Similar Documents

Publication Publication Date Title
WO2023284784A1 (zh) 条码图像修复方法、装置、计算机设备和存储介质
WO2019104879A1 (zh) 表格类图像的信息识别方法、电子装置及可读存储介质
US8977054B2 (en) Candidate identification by image fingerprinting and model matching
KR102435365B1 (ko) 증명서 인식 방법 및 장치, 전자 기기, 컴퓨터 판독 가능한 저장 매체
CN110796082B (zh) 铭牌文本检测方法、装置、计算机设备和存储介质
US20060082475A1 (en) Method, an apparatus and a storage medium for locating QR codes
CN109784342B (zh) 一种基于深度学习模型的ocr识别方法及终端
WO2019200802A1 (zh) 合同影像图片的识别方法、电子装置及可读存储介质
CN109255300B (zh) 票据信息提取方法、装置、计算机设备及存储介质
CN101908136A (zh) 一种表格识别处理方法及系统
US20190163971A1 (en) Text line segmentation method
CN111814598A (zh) 一种基于深度学习框架的财务报表自动识别方法
CN110728687B (zh) 文件图像分割方法、装置、计算机设备和存储介质
CN111611988A (zh) 图片验证码识别方法及装置、电子设备和计算机可读介质
CN114648776B (zh) 一种财务报销数据处理方法和处理系统
CN110008960B (zh) 一种检测字符片段完整性的方法及终端
CN112766275B (zh) 印章文字识别方法、装置、计算机设备和存储介质
CN114332883A (zh) 发票信息识别方法、装置、计算机设备及存储介质
CN112580499A (zh) 文本识别方法、装置、设备及存储介质
CN115205861B (zh) 一种获取异常文字识别区域的方法、电子设备及存储介质
CN113536822B (zh) 二维码校正方法、装置及计算机可读存储介质
CN111241974B (zh) 票据信息获取方法、装置、计算机设备和存储介质
US11386686B2 (en) Method and apparatus to estimate image translation and scale for alignment of forms
CN114037822A (zh) 一种行驶证检测方法和系统
WO2020155484A1 (zh) 基于支持向量机的文字识别方法、装置和计算机设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22841417

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE