CN117829175A - Code scanning method and system based on light compensation of bicolor light source - Google Patents

Code scanning method and system based on light compensation of bicolor light source Download PDF

Info

Publication number
CN117829175A
CN117829175A CN202311669829.6A CN202311669829A CN117829175A CN 117829175 A CN117829175 A CN 117829175A CN 202311669829 A CN202311669829 A CN 202311669829A CN 117829175 A CN117829175 A CN 117829175A
Authority
CN
China
Prior art keywords
image
gray level
code scanning
light source
gray
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.)
Pending
Application number
CN202311669829.6A
Other languages
Chinese (zh)
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.)
Foshan Xincode Electronics Technology Co ltd
Original Assignee
Foshan Xincode Electronics 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 Foshan Xincode Electronics Technology Co ltd filed Critical Foshan Xincode Electronics Technology Co ltd
Priority to CN202311669829.6A priority Critical patent/CN117829175A/en
Publication of CN117829175A publication Critical patent/CN117829175A/en
Pending legal-status Critical Current

Links

Landscapes

  • Image Analysis (AREA)

Abstract

The invention relates to a code scanning method and a system based on light compensation of a bicolor light source, comprising the following steps: acquiring code scanning images shot under the action of a first light source and a second light source as a first image and a second image; respectively graying the first image and the second image to obtain a first gray image and a second gray image; performing light compensation based on the first gray level image and the second gray level image to obtain a compensated gray level image; performing edge detection on the compensated gray level image to find out all edges; taking a closed region formed by all edges together as an ROI region, and carrying out region enhancement on the ROI region by a region enhancement algorithm; and marking all edges, and taking the marked image as a final image for identification to obtain a code scanning result. The invention can highlight the key region of the image code, namely the ROI region, by an image processing method, can greatly increase the probability of successful code scanning and ensures the accurate proceeding of the subsequent image code recognition process.

Description

Code scanning method and system based on light compensation of bicolor light source
Technical Field
The invention relates to the technical field of code scanning identification, in particular to a code scanning method and system based on light compensation of a bicolor light source.
Background
Most of the current code scanning modes are bar codes and two-dimensional codes, and related information content can be obtained by scanning the corresponding bar codes and the two-dimensional codes, so that great convenience can be brought to life and work.
The code scanning mode in the current market usually carries out image code content reading through directly carrying out image shooting, the mode is dependent on-site environmental factors, once the environment where the image code is located is poor, such as insufficient brightness and insufficient tidy image code, the situation that a result cannot be obtained can be caused, the mode of carrying out code scanning through a single light source in an auxiliary clear adding mode is also adopted in the market, and the improvement effect brought by the mode is still poor.
Disclosure of Invention
The invention aims to at least solve one of the defects in the prior art and provides a code scanning method and system based on light compensation of a bicolor light source.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
specifically, a code scanning method based on light compensation of a bicolor light source is provided, which comprises the following steps:
acquiring a code scanning image shot under the action of a first light source as a first image, and taking the code scanning image shot under the action of a second light source as a second image;
respectively graying the first image and the second image to obtain a first gray image and a second gray image;
performing light compensation based on the first gray level image and the second gray level image to obtain a compensated gray level image;
performing edge detection on the compensated gray level image to find out all edges;
taking a closed region formed by all the edges as an ROI region, and carrying out region enhancement on the ROI region by a region enhancement algorithm;
and marking all the edges, and taking the marked image as a final image for identification to obtain a code scanning result.
Further, specifically, the light compensation is performed based on the first gray scale image and the second gray scale image to obtain a compensated gray scale image, which includes,
calculating the global average gray value of the first gray image to be mean_val1, and calculating the global average gray value of the second gray image to be mean_val2;
traversing all pixel points of the first gray level image, subtracting mean_val1 from each pixel point, marking as 0 if the value is negative, obtaining a processed first gray level image, traversing all pixel points of the second gray level image, subtracting mean_val2 from each pixel point, marking as 0 if the value is negative, and obtaining a processed second gray level image;
and taking the average value of the pixel points of the corresponding processed first gray level image and the processed second gray level image as the pixel point of the compensated gray level image for any pixel point, and finally obtaining the compensated gray level image.
Further, specifically, the compensated gray image is subjected to edge detection to find all edges, including,
binarizing the compensated gray level image to obtain a binarized image;
processing the binarized image through an edge detection algorithm to obtain an edge image formed by a plurality of edge pixel points;
traversing the edge image to obtain coordinates of all edge pixel points and total number n;
performing angle calculation based on coordinates of the edge pixel points and positions of the edge pixel points in the edge image to obtain an angle thetan of any edge pixel point;
and counting the number of edge pixel points corresponding to different angles thetan, and reserving the angles of which the number is positioned in front of a preset ranking threshold value i. θi while defining j=0;
step 210, calculating the slope k of the direction corresponding to the angle θj n Taking k j =1/k n θj is included in θi, each edge pixel is projected to a straight line y=k j * Forming corresponding projection points on x, and calculating the distance d from the corresponding projection point of each edge pixel point to the origin of coordinates n
Step 220, for each calculated distance d n Counting the number, and finding out the corresponding distance d with the number ranking being positioned in front of the preset ranking threshold t t
Step 230, finding each corresponding distance d with the number ranking being in front of the preset ranking threshold t t The corresponding edge pixel points form a point set, wherein the point set corresponds to one edge, and a total of t edges are finally obtained;
step 240, let j=j+1, judge j is greater than i, if yes, output all obtained edges, otherwise repeat step 210 to step 240 until the cycle is ended.
Further, specifically, the edge detection algorithm is an edge detection algorithm based on a Canny operator.
The invention also provides a code scanning device based on the light compensation of the bicolor light source, which comprises:
the data acquisition module is used for acquiring a code scanning image shot under the action of a first light source as a first image and taking the code scanning image shot under the action of a second light source as a second image;
the image graying module is used for respectively graying the first image and the second image to obtain a first gray image and a second gray image;
the optical fiber compensation module is used for carrying out light compensation based on the first gray level image and the second gray level image to obtain a compensated gray level image;
the edge detection module is used for carrying out edge detection on the compensated gray level image to find out all edges;
the ROI region highlighting module is used for taking a closed region formed by all the edges together as an ROI region and carrying out region enhancement on the ROI region through a region enhancement algorithm;
and the result display module is used for marking all the edges, and taking the marked image as a final image for identification to obtain a code scanning result.
Further, specifically, the data acquisition module is a bicolor light source code scanning gun.
The beneficial effects of the invention are as follows:
the invention provides a code scanning method and a system based on light compensation of a bicolor light source, which are characterized in that the bicolor light source is used for carrying out irradiation to assist code scanning, and the shooting result is combined to highlight the key region of an image code, namely an ROI (region of interest) region, by an image processing method, so that the probability of successful code scanning can be greatly increased, and the accurate proceeding of the subsequent image code recognition process is ensured.
Drawings
The above and other features of the present disclosure will become more apparent from the detailed description of the embodiments illustrated in the accompanying drawings, in which like reference numerals designate like or similar elements, and which, as will be apparent to those of ordinary skill in the art, are merely some examples of the present disclosure, from which other drawings may be made without inventive effort, wherein:
FIG. 1 is a flow chart of the code scanning method based on the light compensation of the bicolor light source.
Detailed Description
The conception, specific structure, and technical effects produced by the present invention will be clearly and completely described below with reference to the embodiments and the drawings to fully understand the objects, aspects, and effects of the present invention. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The same reference numbers will be used throughout the drawings to refer to the same or like parts.
Embodiment 1, referring to fig. 1, the present invention proposes a code scanning method based on light compensation of a bi-color light source, comprising the following steps:
step 110, acquiring a code scanning image shot under the action of a first light source as a first image, and taking the code scanning image shot under the action of a second light source as a second image;
step 120, respectively graying the first image and the second image to obtain a first gray image and a second gray image;
step 130, performing light compensation based on the first gray scale image and the second gray scale image to obtain a compensated gray scale image;
step 140, performing edge detection on the compensated gray image to find out all edges;
step 150, taking a closed region formed by all the edges as an ROI region, and carrying out region enhancement on the ROI region through a region enhancement algorithm;
and 160, marking all the edges, and taking the marked image as a final image for identification to obtain a code scanning result.
In the preferred embodiment, the auxiliary code scanning is performed by using the bicolor light source, and the key region of the image code, namely the ROI region, is highlighted by combining the shooting result through the image processing method, so that the probability of successful code scanning can be greatly increased, and the accurate proceeding of the subsequent image code recognition process is ensured.
As a preferred embodiment of the present invention, specifically, the light compensation is performed based on the first gray scale image and the second gray scale image to obtain a compensated gray scale image, which includes,
calculating the global average gray value of the first gray image to be mean_val1, and calculating the global average gray value of the second gray image to be mean_val2;
traversing all pixel points of the first gray level image, subtracting mean_val1 from each pixel point, marking as 0 if the value is negative, obtaining a processed first gray level image, traversing all pixel points of the second gray level image, subtracting mean_val2 from each pixel point, marking as 0 if the value is negative, and obtaining a processed second gray level image;
and taking the average value of the pixel points of the corresponding processed first gray level image and the processed second gray level image as the pixel point of the compensated gray level image for any pixel point, and finally obtaining the compensated gray level image.
In the preferred embodiment, by performing the light compensation in the above manner, on the one hand, the background interference of the acquired image when the monochromatic light source irradiates can be removed, and on the other hand, the ROI area of the comprehensive bi-color light source can ensure the complete highlighting of the ROI area.
As a preferred embodiment of the present invention, specifically, performing edge detection on the compensated gray-scale image to find all edges, including,
binarizing the compensated gray level image to obtain a binarized image;
processing the binarized image through an edge detection algorithm to obtain an edge image formed by a plurality of edge pixel points;
traversing the edge image to obtain coordinates of all edge pixel points and total number n;
performing angle calculation based on coordinates of the edge pixel points and positions of the edge pixel points in the edge image to obtain an angle thetan of any edge pixel point; wherein the calculated angle is the edge direction angle of the edge pixel point,
and counting the number of edge pixel points corresponding to different angles thetan, and reserving the angles of which the number is positioned in front of a preset ranking threshold value i. θi while defining j=0;
step 210, calculating the slope k of the direction corresponding to the angle θj n Taking k j =1/k n θj is included in θi, each edge pixel is projected to a straight line y=k j * Forming corresponding projection points on x, and calculating the distance d from the corresponding projection point of each edge pixel point to the origin of coordinates n
Step 220, for each calculated distance d n Counting the number, and finding out the corresponding distance d with the number ranking being positioned in front of the preset ranking threshold t t
Step 230, finding each corresponding distance d with the number ranking being in front of the preset ranking threshold t t The corresponding edge pixel points form a point set, wherein the point set corresponds to one edge, and a total of t edges are finally obtained;
step 240, let j=j+1, judge j is greater than i, if yes, output all obtained edges, otherwise repeat step 210 to step 240 until the cycle is ended.
In the preferred embodiment, the edge direction angle obtained by gradient calculation is adopted to divide the straight lines, and the logic processing in the mode can well distinguish the parallel straight lines, so that the method is more in line with the actual situation of the image code (a plurality of parallel straight lines exist as interference items) to ensure the accuracy of the final straight line division result
As a preferred embodiment of the present invention, the edge detection algorithm is specifically an edge detection algorithm based on Canny operator.
The invention also provides a code scanning device based on the light compensation of the bicolor light source, which comprises:
the data acquisition module is used for acquiring a code scanning image shot under the action of a first light source as a first image and taking the code scanning image shot under the action of a second light source as a second image;
the image graying module is used for respectively graying the first image and the second image to obtain a first gray image and a second gray image;
the optical fiber compensation module is used for carrying out light compensation based on the first gray level image and the second gray level image to obtain a compensated gray level image;
the edge detection module is used for carrying out edge detection on the compensated gray level image to find out all edges;
the ROI region highlighting module is used for taking a closed region formed by all the edges together as an ROI region and carrying out region enhancement on the ROI region through a region enhancement algorithm;
and the result display module is used for marking all the edges, and taking the marked image as a final image for identification to obtain a code scanning result.
As a preferred embodiment of the present invention, specifically, the data acquisition module is a bi-color light source code scanning gun.
In the preferred embodiment, the first image and the second image are acquired in the form of the two-color light source code scanning gun, so that the method is quite convenient, and in addition, a communication module can be arranged in the code scanning gun, and the obtained first image and second image are sent to a terminal or a cloud for corresponding subsequent image analysis processing.
In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules.
The integrated modules, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on this understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or system capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth.
While the present invention has been described in considerable detail and with particularity with respect to several described embodiments, it is not intended to be limited to any such detail or embodiments or any particular embodiment, but is to be construed as providing broad interpretation of such claims by reference to the appended claims in view of the prior art so as to effectively encompass the intended scope of the invention. Furthermore, the foregoing description of the invention has been presented in its embodiments contemplated by the inventors for the purpose of providing a useful description, and for the purposes of providing a non-essential modification of the invention that may not be presently contemplated, may represent an equivalent modification of the invention.
The present invention is not limited to the above embodiments, but is merely preferred embodiments of the present invention, and the present invention should be construed as being limited to the above embodiments as long as the technical effects of the present invention are achieved by the same means. Various modifications and variations are possible in the technical solution and/or in the embodiments within the scope of the invention.

Claims (6)

1. The code scanning method based on the light compensation of the bicolor light source is characterized by comprising the following steps of:
acquiring a code scanning image shot under the action of a first light source as a first image, and taking the code scanning image shot under the action of a second light source as a second image;
respectively graying the first image and the second image to obtain a first gray image and a second gray image;
performing light compensation based on the first gray level image and the second gray level image to obtain a compensated gray level image;
performing edge detection on the compensated gray level image to find out all edges;
taking a closed region formed by all the edges as an ROI region, and carrying out region enhancement on the ROI region by a region enhancement algorithm;
and marking all the edges, and taking the marked image as a final image for identification to obtain a code scanning result.
2. The code scanning method based on the light compensation of the two-color light source according to claim 1, wherein the compensating the light based on the first gray scale image and the second gray scale image to obtain the compensated gray scale image comprises,
calculating the global average gray value of the first gray image to be mean_val1, and calculating the global average gray value of the second gray image to be mean_val2;
traversing all pixel points of the first gray level image, subtracting mean_val1 from each pixel point, marking as 0 if the value is negative, obtaining a processed first gray level image, traversing all pixel points of the second gray level image, subtracting mean_val2 from each pixel point, marking as 0 if the value is negative, and obtaining a processed second gray level image;
and taking the average value of the pixel points of the corresponding processed first gray level image and the processed second gray level image as the pixel point of the compensated gray level image for any pixel point, and finally obtaining the compensated gray level image.
3. The code scanning method based on the light compensation of the bicolor light source according to claim 1, wherein specifically, the method for searching all edges by performing edge detection on the compensated gray image comprises,
binarizing the compensated gray level image to obtain a binarized image;
processing the binarized image through an edge detection algorithm to obtain an edge image formed by a plurality of edge pixel points;
traversing the edge image to obtain coordinates of all edge pixel points and total number n;
performing angle calculation based on coordinates of the edge pixel points and positions of the edge pixel points in the edge image to obtain an angle thetan of any edge pixel point;
counting the number of edge pixel points corresponding to different angles thetan, reserving the angles thetai with the number being in front of a preset ranking threshold value i, and defining j=0;
step 210, calculating the slope k of the direction corresponding to the angle θj n Taking k j =1/k n θj is included in θi, each edge pixel is projected to a straight line y=k j * Forming corresponding projection points on x, and calculating the distance d from the corresponding projection point of each edge pixel point to the origin of coordinates n
Step 220, for each calculated distance d n Counting the number, and finding out the corresponding distance d with the number ranking being positioned in front of the preset ranking threshold t t
Step 230, finding each corresponding distance d with the number ranking being in front of the preset ranking threshold t t The corresponding edge pixel points form a point set, wherein the point set corresponds to one edge, and a total of t edges are finally obtained;
step 240, let j=j+1, judge j is greater than i, if yes, output all obtained edges, otherwise repeat step 210 to step 240 until the cycle is ended.
4. The code scanning method based on the light compensation of the bicolor light source according to claim 3, wherein the edge detection algorithm is specifically an edge detection algorithm based on a Canny operator.
5. Code scanning device based on two-color light source light compensation, its characterized in that includes:
the data acquisition module is used for acquiring a code scanning image shot under the action of a first light source as a first image and taking the code scanning image shot under the action of a second light source as a second image;
the image graying module is used for respectively graying the first image and the second image to obtain a first gray image and a second gray image;
the optical fiber compensation module is used for carrying out light compensation based on the first gray level image and the second gray level image to obtain a compensated gray level image;
the edge detection module is used for carrying out edge detection on the compensated gray level image to find out all edges;
the ROI region highlighting module is used for taking a closed region formed by all the edges together as an ROI region and carrying out region enhancement on the ROI region through a region enhancement algorithm;
and the result display module is used for marking all the edges, and taking the marked image as a final image for identification to obtain a code scanning result.
6. The code scanning device based on the light compensation of the bicolor light source according to claim 5, wherein the data acquisition module is a bicolor light source code scanning gun.
CN202311669829.6A 2023-12-06 2023-12-06 Code scanning method and system based on light compensation of bicolor light source Pending CN117829175A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311669829.6A CN117829175A (en) 2023-12-06 2023-12-06 Code scanning method and system based on light compensation of bicolor light source

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311669829.6A CN117829175A (en) 2023-12-06 2023-12-06 Code scanning method and system based on light compensation of bicolor light source

Publications (1)

Publication Number Publication Date
CN117829175A true CN117829175A (en) 2024-04-05

Family

ID=90503549

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311669829.6A Pending CN117829175A (en) 2023-12-06 2023-12-06 Code scanning method and system based on light compensation of bicolor light source

Country Status (1)

Country Link
CN (1) CN117829175A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030066891A1 (en) * 2001-09-26 2003-04-10 Dariusz J. Madej Decoding algorithm for laser scanning bar code readers
CN110347160A (en) * 2019-07-17 2019-10-18 武汉工程大学 A kind of automatic guide vehicle and its air navigation aid based on dual camera barcode scanning
CN112163443A (en) * 2020-10-20 2021-01-01 汪金玲 Code scanning method, code scanning device and mobile terminal
CN112464679A (en) * 2020-11-23 2021-03-09 苏州摩比信通智能***有限公司 Code scanning method and code scanning equipment
WO2022141418A1 (en) * 2020-12-31 2022-07-07 华为技术有限公司 Image processing method and device
CN217787774U (en) * 2022-07-22 2022-11-11 东集技术股份有限公司 Code scanning equipment with three-color light source
CN116167391A (en) * 2023-03-06 2023-05-26 福建新大陆自动识别技术有限公司 Ultra-wide angle code scanning engine

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030066891A1 (en) * 2001-09-26 2003-04-10 Dariusz J. Madej Decoding algorithm for laser scanning bar code readers
CN110347160A (en) * 2019-07-17 2019-10-18 武汉工程大学 A kind of automatic guide vehicle and its air navigation aid based on dual camera barcode scanning
CN112163443A (en) * 2020-10-20 2021-01-01 汪金玲 Code scanning method, code scanning device and mobile terminal
CN112464679A (en) * 2020-11-23 2021-03-09 苏州摩比信通智能***有限公司 Code scanning method and code scanning equipment
WO2022141418A1 (en) * 2020-12-31 2022-07-07 华为技术有限公司 Image processing method and device
CN217787774U (en) * 2022-07-22 2022-11-11 东集技术股份有限公司 Code scanning equipment with three-color light source
CN116167391A (en) * 2023-03-06 2023-05-26 福建新大陆自动识别技术有限公司 Ultra-wide angle code scanning engine

Similar Documents

Publication Publication Date Title
CN110276754B (en) Surface defect detection method, terminal device and storage medium
CN110866924B (en) Line structured light center line extraction method and storage medium
CN111179243A (en) Small-size chip crack detection method and system based on computer vision
CN108629775B (en) Thermal state high-speed wire rod surface image processing method
CN115082419A (en) Blow-molded luggage production defect detection method
CN111915704A (en) Apple hierarchical identification method based on deep learning
JP2002133426A (en) Ruled line extracting device for extracting ruled line from multiple image
CN112614062A (en) Bacterial colony counting method and device and computer storage medium
CN116503388B (en) Defect detection method, device and storage medium
KR101997048B1 (en) Method for recognizing distant multiple codes for logistics management and code recognizing apparatus using the same
CN110570442A (en) Contour detection method under complex background, terminal device and storage medium
CN111784675A (en) Method and device for processing article texture information, storage medium and electronic equipment
CN111444964A (en) Multi-target rapid image matching method based on self-adaptive ROI (region of interest) division
CN115100104A (en) Defect detection method, device and equipment for glass ink area and readable storage medium
CN111507340A (en) Target point cloud data extraction method based on three-dimensional point cloud data
CN108764343B (en) Method for positioning tracking target frame in tracking algorithm
CN112200053B (en) Form identification method integrating local features
CN112330667B (en) Morphology-based laser stripe center line extraction method
CN111507177B (en) Identification method and device for metering turnover cabinet
Gui et al. A fast caption detection method for low quality video images
CN112818983A (en) Method for judging character inversion by using picture acquaintance
EP4369291A1 (en) Apparatus and method for identifying empty tray
CN117829175A (en) Code scanning method and system based on light compensation of bicolor light source
CN113537253B (en) Infrared image target detection method, device, computing equipment and storage medium
CN115187744A (en) Cabinet identification method based on laser point cloud

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