CN116629291A - Express barcode image intelligent enhancement method and system based on computer vision - Google Patents

Express barcode image intelligent enhancement method and system based on computer vision Download PDF

Info

Publication number
CN116629291A
CN116629291A CN202310904097.8A CN202310904097A CN116629291A CN 116629291 A CN116629291 A CN 116629291A CN 202310904097 A CN202310904097 A CN 202310904097A CN 116629291 A CN116629291 A CN 116629291A
Authority
CN
China
Prior art keywords
bar code
width
express
matching
barcode
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202310904097.8A
Other languages
Chinese (zh)
Other versions
CN116629291B (en
Inventor
余为波
刘艳华
刘景德
王永胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Yige Technology Co ltd
Original Assignee
Shenzhen Yige Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Yige Technology Co ltd filed Critical Shenzhen Yige Technology Co ltd
Priority to CN202310904097.8A priority Critical patent/CN116629291B/en
Publication of CN116629291A publication Critical patent/CN116629291A/en
Application granted granted Critical
Publication of CN116629291B publication Critical patent/CN116629291B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1452Methods for optical code recognition including a method step for retrieval of the optical code detecting bar code edges
    • 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/14131D 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

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

Abstract

The invention relates to the technical field of image data processing, in particular to an intelligent enhancement method and system for an express barcode image based on computer vision. The method has better image enhancement effect on the express barcode image according to the real width possibility.

Description

Express barcode image intelligent enhancement method and system based on computer vision
Technical Field
The invention relates to the technical field of image data processing, in particular to an intelligent express barcode image enhancement method and system based on computer vision.
Background
In the express industry, the express bar code can track the express by scanning the bar code on each express for the identity card of the express, so that the express bar code for detecting the express exists in the express list on each express generally. Express bill is usually pasted on the express surface, and the express bar code is possibly dirty and damaged due to the influence of external factors such as transportation environment in the express transportation process, so that the detection of the express bar code information is influenced. Therefore, when dirt or local damage exists on the express barcode, the express barcode image is usually required to be enhanced, so that the recovery of the express barcode information is realized.
Aiming at the image data characteristics of the express barcode area, the prior art generally realizes the enhancement of the express barcode image through open operation in morphological processing, and further realizes the restoration of the express barcode information. However, the open operation in the morphological processing has good image enhancement effect only when the surface defect of the express barcode is small, and the recovery effect of the express barcode information is poor only by adopting the open operation to process the express barcode image when the surface of the express barcode is stained or damaged with large area. Namely, when the surface of the express barcode is stained or damaged in a large area, the image enhancement effect of the prior art on the express barcode image is poor, and the detection of the express barcode information is affected.
Disclosure of Invention
In order to solve the technical problem that the image enhancement effect on the express barcode image is poor when the larger area of the surface of the express barcode is stained or damaged, the invention aims to provide the intelligent enhancement method and the intelligent enhancement system for the express barcode image based on computer vision, and the adopted technical scheme is as follows:
the invention provides an intelligent enhancement method for an express barcode image based on computer vision, which comprises the following steps:
acquiring an express barcode image, and dividing the express barcode image into express barcode areas through images;
obtaining a straight line segment and an overall bar code direction corresponding to each bar code according to the gray level change characteristics and the position distribution characteristics of the pixel points in the express bar code area; obtaining an external bar code area image containing the straight line segments corresponding to all bar codes according to the straight line segments; traversing the external bar code area image through a straight line perpendicular to the whole bar code direction in the external bar code area image to obtain at least two traversing straight lines; obtaining the matching bar code width of each bar code in each traversing straight line according to the gray value change characteristics of the pixel points on each traversing straight line;
Obtaining the width credibility of each matching bar code width corresponding to each bar code according to the gray value distribution characteristics of the pixel points of each bar code on each traversing straight line and the numerical value distribution characteristics of the matching bar code width; calculating the minimum width difference between the width of each bar code corresponding to each matching bar code and the width of all standard bar codes, and obtaining the real width possibility of each bar code corresponding to the width of each matching bar code according to the minimum width difference and the width reliability, wherein the minimum width difference and the real width possibility are in negative correlation, and the width reliability and the real width possibility are in positive correlation;
and obtaining an express barcode enhancement result according to the real width possibility, and intelligently enhancing the express barcode image according to the express barcode enhancement result.
Further, the obtaining the straight line segment and the whole bar code direction corresponding to each bar code according to the gray scale change characteristic and the position distribution characteristic of the pixel points in the express bar code area comprises the following steps:
acquiring a gray level image of an express barcode area after graying the express barcode area, and performing edge detection on the gray level image of the express barcode area to obtain an edge image of the express barcode; mapping the express barcode edge image into a Hough space corresponding to a polar coordinate through a Hough straight line detection algorithm to obtain a voting value corresponding to each Hough coordinate; calculating a voting value accumulation sum of all Hough coordinates under each angle value, taking the angle value as an independent variable, and taking the voting value accumulation sum as a dependent variable to construct a voting value accumulation curve; a peak point detection algorithm is adopted for the voting value accumulation curve, so that a peak point of the voting value accumulation curve is obtained, and in the peak point of the voting value accumulation curve, a direction corresponding to an angle value of a maximum peak point is taken as an overall bar code direction;
Performing curve fitting on all voting values of angle values corresponding to the whole bar code direction according to the sequence of the polar coordinate distances corresponding to the Hough space from small to large to obtain a voting value change curve, and adopting a peak value point detection algorithm on the voting value change curve to obtain at least two voting value peak values; and obtaining at least two straight line segments from the voting value peak value point through a Hough space function.
Further, the method for acquiring the width of the matching bar code comprises the following steps:
performing curve fitting according to the gray values of the pixel points on each traversing straight line along the extending direction of each traversing straight line to obtain a gray value change curve corresponding to each traversing straight line; and obtaining the wave valley point corresponding to each gray value change curve through a peak value point detection algorithm on the gray value change curve, obtaining the position of the straight line segment corresponding to each bar code in the gray value change curve, using the pixel points corresponding to the wave valley points at two sides of the straight line segment corresponding to each bar code as the matching pixel points corresponding to each bar code, and using the distance between the matching pixel points corresponding to each bar code as the matching bar code width of each bar code in each traversing straight line.
Further, the method for acquiring the width credibility comprises the following steps:
Optionally taking one bar code as a target bar code, taking one traversing straight line as a target traversing straight line, taking the matching bar code width of the target bar code in the target traversing straight line as a target matching bar code width, and taking the ratio of the occurrence times of the numerical value of the target matching bar code width to the number of the traversing straight lines in all the matching bar code widths corresponding to the target bar code as the numerical value distribution characteristic value of the target matching bar code width;
matching the corresponding pixel points of the bar codes in each traversing straight line as the width pixel points of each bar code in each traversing straight line, taking the gray value average value of all the width pixel points in the target traversing straight line as the target integral gray characteristic value, and taking the gray value average value of all the width pixel points of the target bar codes in the target traversing straight line as the target bar code gray characteristic value; taking the difference between the gray scale characteristic value of the target bar code and the integral gray scale characteristic value as a gray scale value distribution characteristic value of the target matching bar code width;
obtaining the width credibility of the target matching bar code width according to the numerical value distribution characteristic value and the gray value distribution characteristic value; the width credibility is positively correlated with the numerical value distribution characteristic value, and the width credibility is negatively correlated with the gray value distribution characteristic value.
Further, the method for obtaining the minimum width difference comprises the following steps:
and acquiring all standard bar codes under the condition that the dimensions of the image of the express bar code are the same, calculating the width difference between each standard bar code and the width of each matching bar code corresponding to each bar code, and taking the minimum value of the width difference corresponding to each bar code as the minimum width difference corresponding to each bar code.
Further, the obtaining the express barcode enhancement result according to the real width possibility includes:
the matching bar code width of each bar code corresponding to the highest real width possibility is used as the first bar code width of each bar code; taking the bar code with the smallest possibility of corresponding to the real width as the bar code to be converted in all the first bar code widths; taking the integral bar code obtained according to the first bar code width of each bar code as a first integral bar code; the express information decoded by the coding information of the first integral bar code is used as first express information; the matching degree obtained by carrying out character matching on the first express information and the text information in the express barcode image is used as a first matching degree, and when the first matching degree is larger than or equal to a preset matching threshold value, the first integral barcode is used as an express barcode enhancement result;
When the first matching degree is smaller than a preset matching threshold value, the matching bar code width of the bar code to be converted, which corresponds to the second highest real width possibility, is used as the second bar code width of the bar code to be converted; taking an integral bar code obtained according to the second bar code width of the bar code to be converted and the first bar code width of each bar code as a second integral bar code; the express information decoded by the coding information of the second integral bar code is used as second express information; performing character matching on the second express information and text information in the express barcode image to obtain a corresponding matching degree as a second matching degree, and taking the second integral barcode as an express barcode enhancement result when the second matching degree is greater than or equal to a preset matching threshold value;
when the second matching degree is smaller than a preset matching threshold value, the matching bar code width of the possibility that the bar code to be converted corresponds to the third highest real width is used as the third bar code width of the bar code to be converted, iteration is continued until the corresponding matching degree is larger than the preset matching threshold value or reaches the preset iteration times, iteration is stopped, the integral bar code corresponding to the iteration stop is used as a final integral bar code, and the matching degree corresponding to the final integral bar code is used as a final matching degree; when the final matching degree is smaller than a preset matching threshold, the express barcode image is considered to be unable to be enhanced, the corresponding first integral barcode is used as an express barcode enhancement result, and a warning is sent out; and when the final matching degree is greater than or equal to a preset matching threshold value, taking the final integral bar code as an express bar code enhancement result.
Further, the method for acquiring the express barcode area comprises the following steps:
and inputting the express barcode image into a trained semantic segmentation network, and outputting a corresponding express barcode area.
Further, the method for acquiring the external bar code area image comprises the following steps:
and acquiring an external rectangle bounding box of the area corresponding to all the straight line segments through an external rectangle algorithm, taking the area corresponding to the external rectangle bounding box as an external bar code area image, wherein the external rectangle bounding box contains all the straight line segments.
The invention also provides an intelligent express barcode image enhancement system based on computer vision, which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the processor realizes any one step of the intelligent express barcode image enhancement method based on computer vision when executing the computer program.
The invention has the following beneficial effects:
in the prior art, the detection of the express bar code is mainly based on the width of the bar code, namely the thickness of a single bar code in the bar code, and when the bar code area is stained or locally damaged, the width information of the bar code is destroyed, so that the bar code information is influenced. The aim of enhancing the express barcode image is to restore the width information of the damaged barcode. Considering that when the barcode area is stained or locally damaged, the damaged width information of the single barcode is usually a small part, so that the embodiment of the invention obtains the matched barcode width representing the barcode width information on the basis of obtaining the whole barcode direction, and performs credibility calculation on each matched barcode width to obtain the most credible width value of each barcode, so that the express barcode information is more accurate. The real width possibility of each matching bar code width is obtained by further combining the difference between each matching bar code width and the standard bar code width, the width information in the express bar code enhancement result is more accurate through the real width possibility, the image enhancement effect on the express bar code image is further improved, and the detection accuracy on the express bar code information is higher. In conclusion, the method has better image enhancement effect on the express barcode image according to the express barcode enhancement result obtained by the real width possibility.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of an intelligent enhancement method for an express barcode image based on computer vision according to an embodiment of the present invention.
Description of the embodiments
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following is a detailed description of specific implementation, structure, characteristics and effects thereof of the intelligent enhancement method and system for the express barcode image based on computer vision according to the invention, which are provided by the invention, with reference to the accompanying drawings and the preferred embodiment. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, 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 invention belongs.
The invention provides a method and a system for intelligently enhancing an express barcode image based on computer vision.
Referring to fig. 1, a flowchart of a method for intelligently enhancing an express barcode image based on computer vision according to an embodiment of the present invention is shown, where the method includes:
step S1: and acquiring an express barcode image, and dividing the express barcode image into express barcode areas through images.
The embodiment of the invention aims to provide an intelligent enhancement method and system for an express barcode image based on computer vision, which are used for enhancing and restoring the express barcode by an image processing method when the express barcode corresponding to the express barcode image is stained or locally damaged, so that accurate express barcode information can be still detected when the express barcode is interfered by the stained or locally damaged. Therefore, the object of image processing, namely the express bar code image, needs to be acquired first.
The embodiment of the invention firstly acquires the express barcode image. According to the embodiment of the invention, the express is placed on the express scanning table, so that the barcode area can be shot by the camera of the express scanning table, and further, the corresponding express barcode image of the express is shot by the camera of the express scanning table, and the obtained express barcode image is usually a top view in consideration of the fact that the camera on the express scanning table is usually above the express scanning table and the lens of the camera is downward. It should be noted that, the practitioner may obtain the barcode image of the express delivery by other modes according to the specific implementation environment, which is not further described herein.
Considering that when the express delivery bar code image is obtained by shooting the express delivery through the camera, the positions of the bar code areas cannot be determined, so that other areas except the bar code areas usually exist in the express delivery bar code image, and in order to process the bar code areas in the express delivery bar code image, the bar code areas in the express delivery bar code image are required to be segmented. The embodiment of the invention obtains the express barcode area through image segmentation on the express barcode image. The express barcode area only comprises an area of the express barcode corresponding to the whole barcode. It should be noted that, the whole bar code in the embodiment of the present invention is an integral bar code, and a single bar code is a single black connected domain in the integral bar code, and is generally rectangular, and the corresponding length is far greater than the width.
Preferably, the method for acquiring the express barcode area comprises the following steps:
and inputting the express barcode image into a trained semantic segmentation network, and outputting a corresponding express barcode area. In the embodiment of the invention, the semantic segmentation network is selected from a third generation yolo (You Only Look Once) neural network, namely a yolo-v3 neural network. The express bar code image is acquired and marked by the person with relevant experience, the pixel points belonging to the bar code area in the express bar code image are marked as 1, the pixel points in other areas are marked as 0, and all marks are further encoded through the single-heat encoding, so that a training set for training the neural network is obtained. And further inputting the express barcode image into a yolo neural network which is trained by a training set, and inputting an express barcode area. It should be noted that, an implementer may select other semantic segmentation networks outside the yolo neural network according to a specific implementation environment, and may also obtain a training set for training the neural network by other methods according to the specific implementation environment; and the third generation yolo neural network and the single thermal encoding are well known in the art, and are not further defined and described herein.
Step S2: obtaining a straight line segment and an integral bar code direction corresponding to each bar code according to the gray level change characteristics and the position distribution characteristics of the pixel points in the express bar code area; obtaining an external bar code area image containing the straight line segments corresponding to all bar codes according to the straight line segments; traversing the external bar code area image through a straight line perpendicular to the direction of the integral bar code in the external bar code area image to obtain at least two traversing straight lines; and obtaining the matching bar code width of each bar code in each traversing straight line according to the gray value change characteristics of the pixel points on each traversing straight line.
Since the main basis of the express barcode detection is the width of the barcode, namely the thickness of a single barcode in the barcode, when the barcode area is stained or locally damaged, the width information of the barcode is destroyed, so that in order to improve the accuracy of the express barcode detection, the width information of each barcode needs to be restored before being destroyed or is close to before being destroyed. Considering that the embodiment of the invention is based on computer vision to realize intelligent enhancement of the express barcode image, namely the express barcode image needs to be analyzed from the perspective of a computer or a machine, and the computer or the machine cannot colloquially understand definition of the width information of the express barcode, so that the express barcode area needs to be further processed to obtain the width information of the express barcode which can be understood by the computer or the machine.
For a computer or a machine, the express barcode area is only an image with gray value characteristics, and the width information of each barcode can be understood as the number of pixels with small gray value change on a straight line perpendicular to the direction of the whole barcode, and in order to enable the number of pixels to correspond to each barcode, the position of each barcode needs to be acquired. Therefore, the embodiment of the invention obtains the straight line segment and the whole bar code direction corresponding to each bar code according to the gray level change characteristic and the position distribution characteristic of the pixel points in the express bar code area. And determining the corresponding position of each bar code through the straight line segment, and conveniently and subsequently acquiring the width information of each bar code by acquiring the direction of the whole bar code.
Preferably, obtaining the straight line segment and the whole bar code direction corresponding to each bar code according to the gray scale change characteristic and the position distribution characteristic of the pixel points in the express bar code area comprises the following steps:
and acquiring a gray level image of the express barcode area after graying the express barcode area, and performing edge detection on the gray level image of the express barcode area to obtain an edge image of the express barcode. The normal express barcode area is usually only provided with two colors of black and white, so that the gray value difference between the area corresponding to each barcode and the non-barcode area in the gray image corresponding to the express barcode area is extremely large, and the corresponding gray information is also changed when the express barcode image is polluted or damaged, so that the edge detection can be carried out according to the gray change characteristics of the express barcode area, the express barcode edge image is obtained, and the analysis is further carried out according to the express barcode edge image. In the embodiment of the present invention, the edge detection algorithm adopts a canny edge detection algorithm, and it should be noted that, according to a specific implementation environment, an operator may adopt other edge detection algorithms besides the canny edge algorithm, and the canny edge detection algorithm is a prior art well known to those skilled in the art, and is not further limited and described herein.
And mapping the express barcode edge image into a Hough space corresponding to the polar coordinates through a Hough straight line detection algorithm to obtain a voting value corresponding to each Hough coordinate. Considering that the embodiment of the invention restores the bar code width information on the basis of each bar code information, when the width characteristics of a certain bar code are completely covered or most of the bar code are covered, the restoration of the bar code width information cannot be realized, namely the embodiment of the invention cannot detect the seriously damaged area of each bar code width information. Therefore, not all the width information of the bar code area which can be processed by the embodiment of the invention is destroyed; and combining the characteristics of the normal bar code areas, namely, each bar code corresponds to a black rectangular connected area, so that the express bar edge image can be processed through Hough straight line detection according to the characteristic that the edges of the rectangles are straight lines on the basis of the edge image. It should be noted that, the hough space and the vote value are technical terms in hough line detection, and hough line detection is a well-known art for those skilled in the art, and are not further limited and described herein.
Calculating a voting value accumulation sum of all Hough coordinates under each angle value, taking the angle value as an independent variable, and taking the voting value accumulation sum as a dependent variable to construct a voting value accumulation curve; and (3) adopting a peak point detection algorithm to the voting value accumulation curve to obtain a peak point of the voting value accumulation curve, wherein the direction corresponding to the angle value of the maximum peak point is taken as the direction of the whole bar code in the peak point of the voting value accumulation curve. Considering the morphological characteristics of the bar codes, namely that the length sides corresponding to the bar codes in the express bar code area are parallel, and most of the length sides of the bar codes in the detectable express bar code area are not destroyed, so that the sum of the voting values corresponding to the angle values of the bar codes in the corresponding length side direction in the corresponding Hough space is usually the largest, namely that the direction corresponding to the maximum peak point in the voting value accumulation curve is the length side direction corresponding to the bar codes, namely the whole bar code direction. It should be noted that the peak detection algorithm is a prior art well known to those skilled in the art, and will not be further described herein and in the subsequent analysis.
Performing curve fitting on all voting values of corresponding angle values in the whole bar code direction according to the sequence of the polar coordinate distances corresponding to the Hough space from small to large to obtain a voting value change curve, and adopting a peak value point detection algorithm on the voting value change curve to obtain at least two voting value peak values; and obtaining at least two straight line segments from the voting value peak value point through a Hough space function. Since the express barcode region representing express information is generally provided with a plurality of barcodes, and a large gray level difference exists between the barcode region and the background region, and the traversing straight line passes through each barcode, at least two voting value peak points can be obtained for the voting value change curve through a peak point detection algorithm, and each barcode corresponds to two voting value peak points under the normal condition. It should be noted that, in addition to the order from the small to the large of the polar coordinate distances corresponding to the hough space, the implementer may also use the order from the large to the small of the polar coordinate distances corresponding to the hough space according to the specific implementation environment, which is not further described herein.
The method comprises the steps of determining the position of each straight line according to a voting value change curve, and obtaining straight line segments corresponding to each bar code according to longer characteristics of the straight line segments corresponding to each bar code by taking the fact that the straight line segments corresponding to the angle values in the whole bar code direction are possibly generated when dirt or damage occurs to an express bar code image into consideration. Because the area corresponding to each normal bar code is a rectangular area, each bar code in the embodiment of the invention corresponds to two detected straight line segments. In the embodiment of the invention, the straight line segment of each peak point in the express barcode edge image is obtained through the Hough space function in MATLAB, and the straight line segment in the express barcode edge image is mapped into the express barcode area, so that the straight line segment required by the embodiment of the invention can be obtained. It should be noted that, the hough space function in MATLAB is well known in the art, and is not further defined and described herein.
Thus, the straight line segment and the whole bar code direction corresponding to each bar code are obtained, and for a normal express bar code, the corresponding standard rectangular area of each bar code is equal at the width corresponding to different length positions, namely the width distribution is very uniform, so that all bar codes can be penetrated through one straight line perpendicular to the whole bar code direction, and the length overlapped with each bar code on the straight line is the bar code width of each bar code. In the embodiment of the invention, the width of each bar code corresponding to different length positions in the corresponding communication domain is different due to the fact that the express bar code area is possibly polluted or damaged, so that the bar code width of each bar code cannot be represented by the corresponding coincident length only through one straight line perpendicular to the direction of the whole bar code, all coincident lengths of each bar code are required to be analyzed, the straight line perpendicular to the direction of the whole bar code corresponding to each length position passes through all bar codes, and each coincident length is analyzed. In order to make the bar code width information obtained by each bar code more accurate, it is necessary to ensure that each straight line perpendicular to the direction of the whole bar code can pass through all bar codes, so that the embodiment of the invention obtains the external bar code area image containing the straight line segments corresponding to all bar codes according to the straight line segments.
Preferably, the method for acquiring the external bar code area image comprises the following steps:
and obtaining an external rectangle bounding box of the area corresponding to all the straight line segments through an external rectangle algorithm, taking the area corresponding to the external rectangle bounding box as an external bar code area image, wherein the external rectangle bounding box contains all the straight line segments. In the embodiment of the invention, the external moment algorithm adopts a point set minimum external moment algorithm. The straight line segment can represent the position of each bar code, and the area formed by all bar codes under normal conditions is a rectangular area, so that the boundary of the image of the external bar code area obtained by the point set minimum external moment algorithm coincides with the boundary of the whole bar code, the width characteristic of each bar code can be conveniently analyzed according to the traversing straight line, and the interference of other areas outside the bar code area is avoided. It should be noted that, the practitioner may acquire the external barcode region image by using other external moment algorithms except the point set minimum external moment algorithm according to the specific implementation environment, and the point set minimum external moment algorithm is a prior art well known to those skilled in the art, and is not further limited and described herein.
Considering that when the barcode area is stained or broken, the corresponding barcode widths are not the same, so that in order to obtain accurate barcode width information, comparison analysis is required to be performed on all barcode widths of each barcode, and therefore all width information corresponding to each barcode needs to be obtained first. Because longer side lengths of rectangular areas corresponding to the bar codes are parallel to each other under normal conditions, and the area corresponding to the whole bar code is a rectangular area, the embodiment of the invention traverses the image of the external bar code area through the straight line perpendicular to the direction of the whole bar code in the image of the external bar code area on the basis of acquiring the image of the external bar code area, so as to obtain at least two traversing straight lines. The length of the line segment, which is overlapped with each bar code by traversing the straight line, can characterize the width of each bar code.
After the traversing straight line is obtained, the width can be represented by the length of a line segment, which coincides with each bar code, of the traversing straight line, and the gray value change of a pixel point on the traversing straight line can be analyzed to obtain the bar code width corresponding to each bar code in consideration of the fact that the area corresponding to each bar code is usually a black area and the background area corresponding to adjacent bar codes is usually white. According to the embodiment of the invention, the matching bar code width of each bar code in each traversing straight line is obtained according to the gray value change characteristics of the pixel points on each traversing straight line. Matching the bar code width is the width information of each bar code through each traversing straight line.
Preferably, the method for acquiring the width of the matching bar code comprises the following steps:
and performing curve fitting according to the gray values of the pixel points on each traversing straight line along the extending direction of each traversing straight line to obtain a gray value change curve corresponding to each traversing straight line. Because the gray value on the edge of the area corresponding to each bar code has larger change, and the gray value in the corresponding area basically does not change, the position of each bar code can be obviously observed through the wave crest and wave trough distribution condition of the gray value change area.
And obtaining the wave valley point corresponding to each gray value change curve through a peak value point detection algorithm on the gray value change curve, obtaining the position of the straight line segment corresponding to each bar code in the gray value change curve, using the pixel points corresponding to the wave valley points at two sides of the straight line segment corresponding to each bar code as the matching pixel points corresponding to each bar code, and using the distance between the matching pixel points corresponding to each bar code as the matching bar code width of each bar code in each traversing straight line. The area corresponding to each bar code is black, and the background area is white, so that the gray value of the corresponding bar code area is smaller and the gray value of the corresponding background area is larger on each traversing straight line, and the area with larger gray value change is usually at two sides of each bar code area, so that the position of the straight line segment can be further combined, and the width information corresponding to each bar code corresponding to each traversing straight line can be represented according to the distance between the valley points, namely the matching pixel points.
Step S3: obtaining the width credibility of each matching bar code width corresponding to each bar code according to the gray value distribution characteristics of the pixel points of each bar code on each traversing straight line and the numerical value distribution characteristics of the matching bar code width; and calculating the minimum width difference between the width of each bar code corresponding to each matching bar code and the width of all standard bar codes, and obtaining the actual width possibility of each bar code corresponding to the width of each matching bar code according to the minimum width difference and the width reliability, wherein the minimum width difference and the actual width possibility are in negative correlation, and the width reliability and the actual width possibility are in positive correlation.
So far, the width of the matched bar code corresponding to each bar code on each traversing straight line is obtained, and the width of the matched bar code corresponding to each bar code on different traversing straight lines is possibly different due to the influence of external factors such as dirt or damage, so that all the width of the matched bar code corresponding to each bar code needs to be analyzed, and the width of the matched bar code with highest reliability is selected as the width information corresponding to each bar code. When each bar code is affected by dirt or damage, the corresponding dirt area or damage area is irregular, so that the width of the matched bar code which is in and out of the original bar code width is random, and the width of the matched bar code which is not affected by dirt or damage is the same, and the corresponding credibility of analysis and characterization can be carried out on the numerical value of each matched bar code width.
In addition, regarding the express bar code which can detect information after image enhancement, the corresponding dirty or damaged area is usually smaller than the image of the external bar code area, so that the bar codes which are affected by the dirty or damaged area are fewer on the same traversing straight line, the gray value of the pixel points of the corresponding bar codes which are affected by the dirty or damaged area on the same traversing straight line is obviously different from the integral gray value, and therefore the gray value distribution characteristics of the pixel points on each traversing straight line can be analyzed to represent the reliability of the width of each matching bar code. According to the gray value distribution characteristics of the pixel points of each bar code on each traversing straight line and the numerical value distribution characteristics of the width of the matched bar code, the width credibility of the width of each matched bar code corresponding to each bar code is obtained.
Preferably, the method for acquiring the width reliability includes:
optionally taking one bar code as a target bar code, taking one traversing straight line as a target traversing straight line, taking the matching bar code width of the target bar code in the target traversing straight line as a target matching bar code width, and taking the ratio of the occurrence times of the numerical value of the target matching bar code width to the number of the traversing straight lines in all the matching bar code widths corresponding to the target bar code as the numerical value distribution characteristic value of the target matching bar code width. Because the values of the matching bar code widths corresponding to the areas affected by dirt or breakage are generally random, and the values of the matching bar code widths not affected are consistent, for any bar code, the larger the value ratio of the corresponding matching bar code width is, the larger the corresponding reliability is, namely the larger the value distribution characteristic value is.
Matching the corresponding pixel points of the bar codes in each traversing straight line as the width pixel points of each bar code in each traversing straight line, taking the gray value average value of all the width pixel points in the target traversing straight line as the target integral gray characteristic value, and taking the gray value average value of all the width pixel points of the target bar codes in the target traversing straight line as the target bar code gray characteristic value; and taking the difference between the gray characteristic value of the target bar code and the integral gray characteristic value as the gray value distribution characteristic value of the target matching bar code width.
When the barcode area is affected by dirt or damage, the gray values of the pixel points in the area affected by dirt or damage in the corresponding barcode area are generally changed, and the area affected by dirt or damage in the image of the external barcode area is generally smaller and randomly distributed, so that the gray values of the corresponding integral pixel points on each traversing straight line are not changed greatly relative to the gray values of the integral pixel points on the normal condition, and the embodiment of the invention calculates the characteristic value of the target integral gray value in a mode of calculating the gray value average value of the pixel points with all widths, and characterizes the gray characteristics of the integral pixel points on the corresponding traversing straight line by the characteristic value of the target integral gray value. The gray value of the local pixel point corresponding to the affected bar code on the same traversing straight line has obvious difference with the gray value of the whole pixel point, so that the gray value average value of the width pixel point of each bar code in the target traversing straight line, namely the gray value characteristic value of the bar code, is compared with the whole gray value characteristic value, and the credibility of each bar code on gray distribution, namely the gray distribution characteristic value, is represented according to the difference between the gray characteristic value of each bar code and the whole gray value characteristic value. The larger the difference between the corresponding target bar code gray scale characteristic value and the integral gray scale value characteristic value is, the larger the corresponding area of the target bar code in the target traversing straight line is affected by dirt or damage, the lower the reliability of the corresponding target matching bar code width is, and the lower the reliability of the corresponding target matching bar code width is.
Obtaining the width credibility of the target matching bar code width according to the numerical value distribution characteristic value and the gray value distribution characteristic value; the width reliability is positively correlated with the numerical distribution characteristic value, and the width reliability is negatively correlated with the gray value distribution characteristic value. The larger the numerical value distribution characteristic value of the target matching bar code width is, the smaller the gray value distribution characteristic value is, and the larger the corresponding width credibility is, so that the width credibility is positively correlated with the numerical value distribution characteristic value, and the width credibility is negatively correlated with the gray value distribution characteristic value. In the embodiment of the invention, the product of the negative correlation mapping value of the gray value distribution characteristic value corresponding to the target matching bar code width and the corresponding numerical value distribution characteristic value is taken as the width credibility of the target matching bar code width. It should be noted that, according to the specific implementation environment, the implementer may distribute the characteristic value and the numerical value according to the gray value by other methods, but the width reliability and the numerical value are required to be guaranteed to be positively correlated, and the width reliability and the gray value are required to be negatively correlated, which is not further described herein.
In the embodiment of the invention, the width of the matching bar code of the L-th bar code on the m-th traversing straight line is used as the width of the target matching bar code, and the method for acquiring the width reliability of the width of the target matching bar code is expressed as follows in the formula: Wherein, the liquid crystal display device comprises a liquid crystal display device,matching of the L-th bar code on the m-th traversing straight lineThe width reliability corresponding to the width of the bar code,is the numerical distribution characteristic value corresponding to the matching bar code width of the L bar code on the m traversing straight line,and exp () is an exponential function based on a natural constant e, and is a gray value distribution characteristic value corresponding to the width of a matching bar code of the L-th bar code on the m-th traversing straight line. And further obtaining the width credibility of all the other matched bar code widths according to the width credibility obtaining method of the target matched bar code width.
In addition, the practitioner can obtain the width confidence of the target matching barcode width through other forms of formulas, such as:
wherein a is a preset first adjustment parameter for preventing denominator from being 0, and in the embodiment of the present invention, the preset first adjustment parameter is set to be 0.01; the meaning of the rest parameters is the same as that of the parameters in the corresponding formula of the method for acquiring the width credibility of the target matching bar code width in the embodiment of the invention, and no further description is given here.
The width credibility corresponding to each bar code is obtained, but dirt or damage in the express bar code area occurs randomly, other interference information possibly occurs, so that the width information of the matching bar code width with the highest credibility corresponding to each bar code is still inaccurate, and further analysis is needed on the basis of the width credibility. Considering that in a normal bar code, only a specific width can represent the code information of the bar code, when the width corresponding to the highest width credibility is larger than the width difference capable of representing the code information of the bar code, the corresponding width information is more unreliable, so that the embodiment of the invention calculates the minimum width difference between the width of each matching bar code corresponding to each bar code and the width of all standard bar codes. The standard bar code width is the width of the coded information that characterizes the bar code.
However, when the standard barcode width is different from the dimension of the whole barcode where the matching barcode width is located in the embodiment of the present invention, that is, the corresponding express barcode area image size is different, the matching barcode width cannot be compared with the standard barcode width. So that the dimension of the standard barcode width is the same as the dimension in the embodiment of the present invention, the embodiment of the present invention stretches the standard barcode corresponding to the standard barcode width. The lengths of the bar codes in the same dimension are the same, so that the lengths of all the standard bar codes are adjusted to be consistent with the length of each bar code, namely the width of the image of the external bar code area in the embodiment of the invention, and the widths of all the standard bar codes are correspondingly adjusted according to the stretching proportion of the corresponding lengths, so that the standard bar code width which can be compared and analyzed with the matched bar code width is obtained. In addition, other methods may be used by the practitioner to obtain the standard barcode width, such as: considering that the express bill is rectangular, coordinate information corresponding to four corner points of the express bill corresponding to the express barcode image corresponding to the embodiment of the invention can be obtained, a perspective transformation matrix between the express bill of the express barcode image corresponding to the embodiment of the invention and a standard express bill with a standard barcode is calculated through a perspective transformation matrix calculation method, and matrix operation is carried out on the perspective transformation matrix and the standard express bill, so that the standard express bill and the express bill of the express barcode image corresponding to the embodiment of the invention are in the same coordinate system, namely in the same dimension, standard barcode information of the standard express bill is further obtained, and in order to enable subsequent calculation to be more accurate, transformation is generally required to be carried out on a plurality of standard express bills, and all standard barcode information is contained in the obtained standard barcode. It should be noted that, the perspective transformation matrix calculation method is a prior art well known to those skilled in the art, and is aimed at adjusting the standard barcode and the barcode in the embodiment of the present invention to the same dimension, which is not further limited and described herein.
Further obtaining the minimum width difference between the width of each matching bar code and the width of all standard bar codes, namely, for each matching bar code width, calculating the width difference between the width of each matching bar code and all standard bar codes, and taking the minimum value of the width difference as the minimum width difference of each matching bar code width. The error of determining the bar code width information only according to the width credibility is reduced through the minimum width difference based on the template matching idea, and when the minimum width difference is larger, the larger the corresponding matching bar code width and the standard bar code width difference is, the more unreliable the corresponding width information is.
Thus, the minimum width difference and the width reliability of the width of each matching bar code are obtained, so that accurate width information of each bar code is obtained. According to the embodiment of the invention, the real width possibility of each bar code corresponding to the width of each matching bar code is obtained according to the minimum width difference and the width reliability, and the possibility that the width of each matching bar code belongs to the real width information of the corresponding bar code is represented by the real width possibility. As the minimum width difference of the corresponding matching bar code width is smaller, when the width credibility is larger, the corresponding width information is less credible, namely the corresponding real width is less likely. The minimum width difference is inversely related to the true width probability and the width confidence is positively related to the true width probability. In the embodiment of the invention, the product of the minimum width difference of the width of each matching bar code subjected to negative correlation mapping and the width reliability is used as the actual width possibility of the width of each matching bar code. It should be noted that, the practitioner may obtain the actual width probability according to the minimum width difference and the width reliability by other methods according to the specific implementation environment, but it needs to be ensured that the minimum width difference is inversely related to the actual width probability, and the width reliability is positively related to the actual width probability, which will not be further described herein.
In the embodiment of the invention, the method for acquiring the real width possibility of the width of the matching bar code of the L-th bar code on the m-th traversing straight line is expressed as follows in the formula:wherein, the liquid crystal display device comprises a liquid crystal display device,for the true width probability of the L-th barcode matching the width of the barcode on the m-th traversal line,for the width credibility corresponding to the width of the matching bar code of the L-th bar code on the m-th traversing straight line,for the minimum width difference corresponding to the matching bar code width of the L-th bar code on the m-th traversing straight line, exp () is an exponential function with a natural constant e as low. And further obtaining the real width possibility of all the matched bar code widths according to the method for obtaining the real width possibility of the matched bar code widths of the L-th bar code on the m-th traversing straight line.
In addition, the practitioner may obtain the corresponding real width likelihood through other forms of formulas, such as:
wherein, for presetting a second adjustment parameter for preventing the denominator from being 0, in the embodiment of the present invention, the first adjustment parameter is preset to be 0.01; the meaning of the rest parameters is the same as the formula corresponding to the method for obtaining the possibility of the true width of the matching bar code width of the L-th bar code on the m-th traversing straight line in the embodiment of the invention, and no further description is given here.
Step S4: and obtaining an express barcode enhancement result according to the real width possibility, and intelligently enhancing the express barcode image according to the express barcode enhancement result.
The method and the device have the advantages that the real width possibility that each bar code corresponds to the width of all the matched bar codes is obtained, the width information of each bar code can be further obtained according to the real width possibility, the image enhancement of the express bar code is completed through the obtained width information, and the express bar code enhancement result is obtained according to the real width possibility.
Preferably, obtaining the express barcode enhancement result according to the real width possibility includes:
according to the obtaining process of the real width probability, in the real width probability of all the matching bar code widths corresponding to each bar code, the higher the corresponding real width probability is, the more the corresponding matching bar code width accords with the real bar code width information, and each bar code can only correspond to one width information, so that the matching bar code width with the highest real probability is selected as the width information of the corresponding bar code first.
The embodiment of the invention takes the matching bar code width of which the highest real width possibility corresponds to each bar code as the first bar code width of each bar code; taking the bar code with the smallest possibility of corresponding to the real width as the bar code to be converted in all the first bar code widths; taking the integral bar code obtained according to the first bar code width of each bar code as a first integral bar code; the express information decoded by the coding information of the first integral bar code is used as first express information; and taking the matching degree obtained by carrying out character matching on the first express information and the text information in the express barcode image as a first matching degree, and taking the first integral barcode as an express barcode enhancement result when the first matching degree is larger than or equal to a preset matching threshold value. In the embodiment of the present invention, the preset matching threshold is set to 0.9, and the practitioner can select the size of the preset matching threshold according to the specific implementation environment, which is not further limited and described herein.
The character matching process specifically includes that text information extracted from an express bill area, namely an express barcode image, through a neural network is judged whether the text information and the express information decoded by the coding information exist or not, namely, the number of the text information extracted from the express bill area by the text information in the express information decoded by the coding information is the same, and the ratio of the text information in the express information decoded by the coding information to the total number of the text information in the express information is used as the corresponding matching degree. Therefore, the matching degree of the whole bar code needs to be judged, when the matching degree is low, the fact that the corresponding bar code cannot represent accurate express information is explained, the express bar code is greatly affected by dirt or damage, and the whole bar code needs to be continuously updated to obtain an accurate express bar code enhancement result. In the embodiment of the present invention, the neural network is a LeNet neural network, and it should be noted that the LeNet neural network is a prior art well known to those skilled in the art, and is not an important research content of the embodiment of the present invention, and the training process and the use method thereof are not further limited and described herein.
When the first matching degree is larger than or equal to a preset matching threshold value, the condition that the barcode image is less affected by dirt or damage is indicated, the corresponding image enhancement effect of the corresponding first integral barcode is good, and the obtained express barcode enhancement result is accurate.
Considering that when part of bar codes are seriously missing or seriously affected by dirt, the code information corresponding to the matching bar code width with the highest real width possibility still possibly has errors, namely the corresponding first matching degree is smaller than a preset matching threshold value, so that the express bar codes need to be further processed. It should be noted that, when there is a defect or dirt in the barcode area in the normal case, the corresponding area is usually smaller and irregular, so the corresponding first matching degree is usually greater than or equal to the preset matching threshold, so the first matching degree is smaller than the preset matching threshold and is rare, so the area with serious defect or serious influence of dirt is usually less, and therefore, the embodiment of the invention adjusts the barcode to be converted with minimum possibility of real width.
In the embodiment of the invention, when the first matching degree is smaller than a preset matching threshold value, the matching bar code width of the bar code to be converted, which corresponds to the second highest real width possibility, is used as the second bar code width of the bar code to be converted; taking an integral bar code obtained according to the second bar code width of the bar code to be converted and the first bar code width of each bar code as a second integral bar code; the express information decoded by the coding information of the second integral bar code is used as second express information; and performing character matching on the second express information and the text information in the express barcode image to obtain a corresponding matching degree as a second matching degree, and taking the second integral barcode as an express barcode enhancement result when the second matching degree is greater than or equal to a preset matching threshold value. It should be noted that, similar to the matching degree processing method of the first integral bar code, the processing method of the second integral bar code is equivalent to an iterative process, and the meaning corresponding to the process of the processing method of the second integral bar code is not further described herein.
When the second matching degree is smaller than a preset matching threshold value, the matching bar code width of the bar code to be converted, which corresponds to the third highest real width possibility, is used as the third bar code width of the bar code to be converted, iteration is continued, namely, the whole bar code obtained according to the third bar code width of the bar code to be converted and the first bar code width of each bar code is used as a third whole bar code; the express information decoded by the encoded information of the third integral bar code is used as third express information; and performing character matching on the third express information and the text information in the express barcode image to obtain a corresponding matching degree as a third matching degree, and taking the third integral barcode as an express barcode enhancement result when the third matching degree is greater than or equal to a preset matching threshold value. And when the third matching degree is smaller than the preset matching threshold value, the matching bar code width of the bar code to be converted, which corresponds to the real width possibility of the fourth high, is used as the fourth bar code width of the bar code to be converted, and iteration is continued.
Stopping iteration until the corresponding matching degree is larger than a preset matching threshold value or the preset iteration times are reached, taking the corresponding integral bar code as a final integral bar code when the iteration is stopped, and taking the matching degree corresponding to the final integral bar code as a final matching degree; when the final matching degree is smaller than a preset matching threshold, the express barcode image is considered to be unable to be enhanced, and the corresponding first integral barcode is taken as an express barcode enhancement result; and when the final matching degree is greater than or equal to a preset matching threshold value, taking the final integral bar code as an express bar code enhancement result. When the final matching degree is still smaller than the preset matching threshold value, the text information corresponding to the corresponding express bill is not matched with the express barcode image originally, or the express bill is indicated to have serious dirt or damage defects, so that the express bill is warned, and an implementer can confirm the express bill image specifically. In the embodiment of the invention, the preset iteration number is set to 3. It should be noted that, the implementer may set the preset iteration number according to the specific implementation environment, and the preset iteration number is usually smaller in general, which will not be further described herein.
For example, if there are A, B, C barcodes in the express barcode area, each barcode corresponds to five matching barcode widths, where the probability of the real width corresponding to barcode a is the smallest; the corresponding bar code A is the bar code to be converted, the matching bar code width of the highest real width possibility of each bar code is firstly taken as the first bar code width of each bar code in the three bar codes A, B, C, the corresponding first integral bar code A 'B' C 'is obtained according to the first bar code width corresponding to the three bar codes A, B, C, the character matching is carried out on the express delivery information after the encoding information of the first integral bar code is decoded, the first matching degree of the first integral bar code is obtained, and when the first matching degree is larger than or equal to a preset matching threshold value, the first integral bar code A' B 'C' is the express delivery bar code enhancement result, and the iteration number is 1 at the moment.
When the first matching degree is smaller than the preset matching threshold, the second highest real width possibility of the bar code A to be converted is used as a corresponding second bar code width, a corresponding second integral bar code A '' B 'C' is further calculated according to the second bar code width of the bar code A and the first bar code width of the bar code B, C, namely, the second matching degree is further calculated, and when the second matching degree is larger than or equal to the preset matching threshold, the second integral bar code A '' B 'C' is an express bar code enhancement result, and the iteration number is 2.
When the second matching degree is smaller than the preset matching threshold, the third highest real width possibility of the bar code A to be converted is used as a corresponding third bar code width, the corresponding third whole bar code A '' 'B' C 'is further calculated according to the third bar code width of the bar code A and the first bar code width of the bar code B, C, namely, the third matching degree is further calculated, and when the third matching degree is larger than or equal to the preset matching threshold, the third whole bar code A' '' B 'C' is an express bar code enhancement result, and the iteration number is 3.
When the third matching degree is smaller than the preset matching threshold, the fourth highest real width possibility of the bar code A to be converted is used as a corresponding fourth bar code width, the matching degree of the fourth integral bar code A '' '' B 'C' is further calculated according to the fourth bar code width of the bar code A and the first bar code width of the bar code B, C, namely, the fourth matching degree, and the iteration number is 4 and is larger than the preset iteration number, namely, the fourth integral bar code A '' '' B 'C' is the final integral bar code, and the fourth matching degree is the final matching degree; if the fourth matching degree is greater than or equal to the preset matching threshold value, the fourth integral bar code A '' '' B 'C' is the enhancement result of the express bar code; if the final matching degree, namely the fourth matching degree, is still smaller than the preset matching threshold, the fact that the express barcode image corresponding to the express barcode region where the barcode A, B, C is located cannot be enhanced is indicated, the corresponding first integral barcode is used as an express barcode enhancement result, and a warning is further sent out to prove that the express barcode image cannot be enhanced.
Thus, the express delivery bar code enhancement result of the express delivery bar code area is obtained, and intelligent enhancement of the express delivery bar code image is further realized according to the express delivery bar code enhancement result. In the embodiment of the invention, the bar codes in the express bar code area are replaced by the integral bar codes corresponding to the express bar code enhancement result, so that intelligent enhancement of the express bar code image is completed.
In summary, the position and the whole direction corresponding to each bar code are determined according to the gray value change and the position of the pixel point in the express bar code area corresponding to the express bar code image, the width of the matched bar code is obtained by analyzing the gray value change of the pixel point on the traversing straight line based on the position and the whole direction, the width reliability is obtained according to the numerical distribution characteristics of the width of the matched bar code and the gray value distribution characteristics of the corresponding pixel point, the minimum width difference between the width of each matched bar code and the standard bar code is calculated, the real width possibility is obtained by combining the width reliability, the express bar code reinforcing result is obtained according to the real width possibility, and the intelligent reinforcement of the express bar code image is realized. The method has better image enhancement effect on the express barcode image according to the real width possibility.
The invention also provides an intelligent express barcode image enhancement system based on computer vision, which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the processor realizes any one step of the intelligent express barcode image enhancement method based on computer vision when executing the computer program.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.

Claims (9)

1. The intelligent express barcode image enhancement method based on computer vision is characterized by comprising the following steps of:
acquiring an express barcode image, and dividing the express barcode image into express barcode areas through images;
Obtaining a straight line segment and an overall bar code direction corresponding to each bar code according to the gray level change characteristics and the position distribution characteristics of the pixel points in the express bar code area; obtaining an external bar code area image containing the straight line segments corresponding to all bar codes according to the straight line segments; traversing the external bar code area image through a straight line perpendicular to the whole bar code direction in the external bar code area image to obtain at least two traversing straight lines; obtaining the matching bar code width of each bar code in each traversing straight line according to the gray value change characteristics of the pixel points on each traversing straight line;
obtaining the width credibility of each matching bar code width corresponding to each bar code according to the gray value distribution characteristics of the pixel points of each bar code on each traversing straight line and the numerical value distribution characteristics of the matching bar code width; calculating the minimum width difference between the width of each bar code corresponding to each matching bar code and the width of all standard bar codes, and obtaining the real width possibility of each bar code corresponding to the width of each matching bar code according to the minimum width difference and the width reliability, wherein the minimum width difference and the real width possibility are in negative correlation, and the width reliability and the real width possibility are in positive correlation;
And obtaining an express barcode enhancement result according to the real width possibility, and intelligently enhancing the express barcode image according to the express barcode enhancement result.
2. The intelligent enhancement method of the express barcode image based on computer vision according to claim 1, wherein the obtaining the straight line segment and the whole barcode direction corresponding to each barcode according to the gray level change characteristic and the position distribution characteristic of the pixel points in the express barcode region comprises:
acquiring a gray level image of an express barcode area after graying the express barcode area, and performing edge detection on the gray level image of the express barcode area to obtain an edge image of the express barcode; mapping the express barcode edge image into a Hough space corresponding to a polar coordinate through a Hough straight line detection algorithm to obtain a voting value corresponding to each Hough coordinate; calculating a voting value accumulation sum of all Hough coordinates under each angle value, taking the angle value as an independent variable, and taking the voting value accumulation sum as a dependent variable to construct a voting value accumulation curve; a peak point detection algorithm is adopted for the voting value accumulation curve, so that a peak point of the voting value accumulation curve is obtained, and in the peak point of the voting value accumulation curve, a direction corresponding to an angle value of a maximum peak point is taken as an overall bar code direction;
Performing curve fitting on all voting values of angle values corresponding to the whole bar code direction according to the sequence of the polar coordinate distances corresponding to the Hough space from small to large to obtain a voting value change curve, and adopting a peak value point detection algorithm on the voting value change curve to obtain at least two voting value peak values; and obtaining at least two straight line segments from the voting value peak value point through a Hough space function.
3. The intelligent enhancement method for the express barcode image based on computer vision according to claim 1, wherein the acquisition method for the matching barcode width comprises the following steps:
performing curve fitting according to the gray values of the pixel points on each traversing straight line along the extending direction of each traversing straight line to obtain a gray value change curve corresponding to each traversing straight line; and obtaining the wave valley point corresponding to each gray value change curve through a peak value point detection algorithm on the gray value change curve, obtaining the position of the straight line segment corresponding to each bar code in the gray value change curve, using the pixel points corresponding to the wave valley points at two sides of the straight line segment corresponding to each bar code as the matching pixel points corresponding to each bar code, and using the distance between the matching pixel points corresponding to each bar code as the matching bar code width of each bar code in each traversing straight line.
4. The intelligent enhancement method for the express barcode image based on computer vision according to claim 1, wherein the method for obtaining the width credibility comprises the following steps:
optionally taking one bar code as a target bar code, taking one traversing straight line as a target traversing straight line, taking the matching bar code width of the target bar code in the target traversing straight line as a target matching bar code width, and taking the ratio of the occurrence times of the numerical value of the target matching bar code width to the number of the traversing straight lines in all the matching bar code widths corresponding to the target bar code as the numerical value distribution characteristic value of the target matching bar code width;
matching the corresponding pixel points of the bar codes in each traversing straight line as the width pixel points of each bar code in each traversing straight line, taking the gray value average value of all the width pixel points in the target traversing straight line as the target integral gray characteristic value, and taking the gray value average value of all the width pixel points of the target bar codes in the target traversing straight line as the target bar code gray characteristic value; taking the difference between the gray scale characteristic value of the target bar code and the integral gray scale characteristic value as a gray scale value distribution characteristic value of the target matching bar code width;
Obtaining the width credibility of the target matching bar code width according to the numerical value distribution characteristic value and the gray value distribution characteristic value; the width credibility is positively correlated with the numerical value distribution characteristic value, and the width credibility is negatively correlated with the gray value distribution characteristic value.
5. The intelligent enhancement method for the express barcode image based on computer vision according to claim 1, wherein the method for obtaining the minimum width difference comprises the following steps:
and acquiring all standard bar codes under the condition that the dimensions of the image of the express bar code are the same, calculating the width difference between each standard bar code and the width of each matching bar code corresponding to each bar code, and taking the minimum value of the width difference corresponding to each bar code as the minimum width difference corresponding to each bar code.
6. The intelligent enhancement method for the express delivery bar code image based on the computer vision according to claim 1, wherein the obtaining the enhancement result of the express delivery bar code according to the real width possibility comprises the following steps:
the matching bar code width of each bar code corresponding to the highest real width possibility is used as the first bar code width of each bar code; taking the bar code with the smallest possibility of corresponding to the real width as the bar code to be converted in all the first bar code widths; taking the integral bar code obtained according to the first bar code width of each bar code as a first integral bar code; the express information decoded by the coding information of the first integral bar code is used as first express information; the matching degree obtained by carrying out character matching on the first express information and the text information in the express barcode image is used as a first matching degree, and when the first matching degree is larger than or equal to a preset matching threshold value, the first integral barcode is used as an express barcode enhancement result;
When the first matching degree is smaller than a preset matching threshold value, the matching bar code width of the bar code to be converted, which corresponds to the second highest real width possibility, is used as the second bar code width of the bar code to be converted; taking an integral bar code obtained according to the second bar code width of the bar code to be converted and the first bar code width of each bar code as a second integral bar code; the express information decoded by the coding information of the second integral bar code is used as second express information; performing character matching on the second express information and text information in the express barcode image to obtain a corresponding matching degree as a second matching degree, and taking the second integral barcode as an express barcode enhancement result when the second matching degree is greater than or equal to a preset matching threshold value;
when the second matching degree is smaller than a preset matching threshold value, the matching bar code width of the possibility that the bar code to be converted corresponds to the third highest real width is used as the third bar code width of the bar code to be converted, iteration is continued until the corresponding matching degree is larger than the preset matching threshold value or reaches the preset iteration times, iteration is stopped, the integral bar code corresponding to the iteration stop is used as a final integral bar code, and the matching degree corresponding to the final integral bar code is used as a final matching degree; when the final matching degree is smaller than a preset matching threshold, the express barcode image is considered to be unable to be enhanced, the corresponding first integral barcode is used as an express barcode enhancement result, and a warning is sent out; and when the final matching degree is greater than or equal to a preset matching threshold value, taking the final integral bar code as an express bar code enhancement result.
7. The intelligent enhancement method for the express delivery bar code image based on computer vision according to claim 1, wherein the acquisition method for the express delivery bar code area comprises the following steps:
and inputting the express barcode image into a trained semantic segmentation network, and outputting a corresponding express barcode area.
8. The intelligent enhancement method for the express barcode image based on computer vision according to claim 1, wherein the acquisition method for the external barcode region image comprises the following steps:
and acquiring an external rectangle bounding box of the area corresponding to all the straight line segments through an external rectangle algorithm, taking the area corresponding to the external rectangle bounding box as an external bar code area image, wherein the external rectangle bounding box contains all the straight line segments.
9. An intelligent express bar code image enhancement system based on computer vision, comprising a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the steps of the method according to any one of claims 1-8 when executing the computer program.
CN202310904097.8A 2023-07-24 2023-07-24 Express barcode image intelligent enhancement method and system based on computer vision Active CN116629291B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310904097.8A CN116629291B (en) 2023-07-24 2023-07-24 Express barcode image intelligent enhancement method and system based on computer vision

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310904097.8A CN116629291B (en) 2023-07-24 2023-07-24 Express barcode image intelligent enhancement method and system based on computer vision

Publications (2)

Publication Number Publication Date
CN116629291A true CN116629291A (en) 2023-08-22
CN116629291B CN116629291B (en) 2024-02-06

Family

ID=87638591

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310904097.8A Active CN116629291B (en) 2023-07-24 2023-07-24 Express barcode image intelligent enhancement method and system based on computer vision

Country Status (1)

Country Link
CN (1) CN116629291B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002269491A (en) * 2001-03-08 2002-09-20 Glory Ltd Bar code recognizing method, and device and program therefor
US20110290877A1 (en) * 2010-06-01 2011-12-01 Fujian Newland Computer Co., Ltd. Barcode decoding chip
US20130256417A1 (en) * 2010-12-16 2013-10-03 Lg Innotek Co., Ltd. Apparatus and method for recognizing barcode
CN109697382A (en) * 2018-12-18 2019-04-30 福州图腾易讯信息技术有限公司 A kind of linear code edge distortion processing method and equipment
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN115759148A (en) * 2023-01-10 2023-03-07 深圳思谋信息科技有限公司 Image processing method, image processing device, computer equipment and computer readable storage medium
CN115994904A (en) * 2023-03-22 2023-04-21 山东万重山电子有限公司 Garment steamer panel production quality detection method based on computer vision

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002269491A (en) * 2001-03-08 2002-09-20 Glory Ltd Bar code recognizing method, and device and program therefor
US20110290877A1 (en) * 2010-06-01 2011-12-01 Fujian Newland Computer Co., Ltd. Barcode decoding chip
US20130256417A1 (en) * 2010-12-16 2013-10-03 Lg Innotek Co., Ltd. Apparatus and method for recognizing barcode
CN109697382A (en) * 2018-12-18 2019-04-30 福州图腾易讯信息技术有限公司 A kind of linear code edge distortion processing method and equipment
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN115759148A (en) * 2023-01-10 2023-03-07 深圳思谋信息科技有限公司 Image processing method, image processing device, computer equipment and computer readable storage medium
CN115994904A (en) * 2023-03-22 2023-04-21 山东万重山电子有限公司 Garment steamer panel production quality detection method based on computer vision

Also Published As

Publication number Publication date
CN116629291B (en) 2024-02-06

Similar Documents

Publication Publication Date Title
Lu et al. Perspective rectification of document images using fuzzy set and morphological operations
WO2020147398A1 (en) Reproduced image detection method and device, computer device and storage medium
CN112233116B (en) Concave-convex mark visual detection method based on neighborhood decision and gray level co-occurrence matrix description
Yoo et al. Image matching using peak signal-to-noise ratio-based occlusion detection
CN109492642B (en) License plate recognition method, license plate recognition device, computer equipment and storage medium
Rosenfeld Image pattern recognition
CN111899270B (en) Card frame detection method, device, equipment and readable storage medium
CN111626941A (en) Document correction method based on deep learning semantic segmentation
CN114494017B (en) Method, device, equipment and medium for adjusting DPI (deep packet inspection) image according to scale
CN112364862B (en) Histogram similarity-based disturbance deformation Chinese character picture matching method
CN110660072A (en) Method and device for identifying straight line edge, storage medium and electronic equipment
CN110288040B (en) Image similarity judging method and device based on topology verification
US6587576B1 (en) Method of quantifying the quality of a gray scale image of a document and an apparatus therefor
CN110889304A (en) Two-dimensional code quality evaluation method and device, storage medium, electronic device and system
CN112258532B (en) Positioning and segmentation method for callus in ultrasonic image
CN116629291B (en) Express barcode image intelligent enhancement method and system based on computer vision
CN111652117B (en) Method and medium for segmenting multiple document images
CN113139535A (en) OCR document recognition method
Fan et al. Skew detection in document images based on rectangular active contour
CN115359449B (en) Automatic identification method and system for turnout notch image of point switch
CN116309561A (en) Surface defect identification method based on anti-creeping insulating material
CN116469090A (en) Method and device for detecting code spraying pattern, electronic equipment and storage medium
CN113920068B (en) Body part detection method and device based on artificial intelligence and electronic equipment
CN112085683A (en) Depth map reliability detection method in significance detection
Partio et al. Texture retrieval using ordinal co-occurrence features

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant