MINISTRY OF EDUCATION AND TRAINING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION FACULTY FOR HIGH QUALITY TRAINING Ho Chi Minh City, Febuary, 2023 SKL 0 1 0 4 5 3 GRADUATION
Trang 1MINISTRY OF EDUCATION AND TRAINING
HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION
FACULTY FOR HIGH QUALITY TRAINING
Ho Chi Minh City, Febuary, 2023
SKL 0 1 0 4 5 3
GRADUATION THESIS MECHANTRONICS ENGINEERING TECHONOLOGY
PRODUCT CLASSIFICATION USING BARCODE
LE NGUYEN ANH KHOA BUI DINH NAM THANH ADVISOR: TRAN VI DO
STUDENT: TANG HOANG LONG
Trang 2HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION
FACULTY FOR HIGH QUALITY TRAINING
Ho Chi Minh City
Trang 3HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION
FACULTY FOR HIGH QUALITY TRAINING
Ho Chi Minh City
Trang 4THE SOCIALIST REPUBLIC OF
GRADUATION PROJECT ASSIGNMENT
Student name: Tang Hoang Long Student ID: 18146045
Student name: Le Nguyen Anh Khoa Student ID: 18146034
Student name: Bui Dinh Nam Thanh Student ID: 18146059
Major: Mechatronics Engineering Class: 18146CLA
Advisor: Tran Vi Do Phone number:
Date of assignment: Date of submission:
1 Project title: PRODUCT CLASSIFICATION USING BARCODE
2 Initial materials provided by the advisor: _
3 Content of the project: _
4 Final product:
CHAIR OF THE PROGRAM
(Sign with full name)
ADVISOR
(Sign with full name)
Trang 5THE SOCIALIST REPUBLIC OF
VIETNAM
Independence – Freedom– Happiness
-
Ho Chi Minh City, Day Month…….,
Year… …
ADVISOR’S EVALUATION SHEET Student name: Tang Hoang Long Student ID: 18146045 Student name: Le Nguyen Anh Khoa Student ID: 18146034 Student name: Bui Dinh Nam Thanh Student ID: 18146059 Major: Mechatronics Engineering Project title: PRODUCT CLASSIFICATION USING BARCODE RO Technology Advisor: Mr Tran Vi Do EVALUATION 1 Content of the project:
Trang 6
2 Strengths:
3 Weaknesses:
4 Approval for oral defense? (Approved or denied)
5 Overall evaluation: (Excellent, Good, Fair, Poor)
6 Mark: … (in words: )
Ho Chi Minh City, Day , Month… , Year…
ADVISOR
(Sign with full name)
Trang 7THE SOCIALIST REPUBLIC OF
VIETNAM
Independence – Freedom– Happiness
-
Ho Chi Minh City, Day Month…….,
Year… …
PRE-DEFENSE EVALUATION SHEET Student name: Tang Hoang Long Student ID: 18146045 Student name: Le Nguyen Anh Khoa Student ID: 18146034 Student name: Bui Dinh Nam Thanh Student ID: 18146057 Major: Mechatronics Engineering Project title: PRODUCT CLASSIFICATION USING BARCODE EVALUATION 1 Content and workload of the project
2 Strengths:
Trang 8
3 Weaknesses:
4 Approval for oral defense? (Approved or denied)
5 Overall evaluation: (Excellent, Good, Fair, Poor)
6 Mark: … (in words: )
Ho Chi Minh City, Day , Month……., Year …
REVIEWER
(Sign with full name)
Trang 9THE SOCIALIST REPUBLIC OF
VIETNAM
Independence – Freedom– Happiness
-
Ho Chi Minh City, Day Month…….,
Year… …
EVALUATION SHEET OF DEFENSE COMMITTEE MEMBER Student name: Tang Hoang Long Student ID: 18146045 Student name: Le Nguyen Anh Khoa Student ID: 18146034 Student name: Bui Dinh Nam Thanh Student ID: 18146059 Major: Mechatronics Engineering Project title: PRODUCT CLASSIFICATION USING BARCODE Name of Defense Committee Member:
EVALUATION 1 Content and workload of the project
2 Strengths:
Trang 10
3 Weaknesses:
4 Overall evaluation: (Excellent, Good, Fair, Poor)
5.Mark:……….(in words: )
Ho Chi Minh City, Day Month……., Year….…
COMMITTEE MEMBER
(Sign with full name)
Trang 11Contents
FIGURES 1
ACKNOWLEDGMENT 3
ABSTRACT 4
CHAPTER 1 OVERVIEW OF THE TOPIC 5
1.1 Question 5
1.2 Object of the research 6
1.3 Research method 6
1.4 Research content 6
1.5 Research limit 7
CHAPTER 2 THEORETICAL BASIS 8
2.1 Overview of product categories 8
2.1.1 Methods of product classification 8
2.1.2 Product classification applied image processing 8
2.2 Overview of image processing 9
2.2.1 Concepts of image processing 10
2.2.2 Basic problems in image processing 11
2.2.3 OpenCV library and image processing methods used in the project 13
2.3 Overview of Barcode detection 18
2.3.2 Barcode types 20
2.3.3 Pyzbar Detection 24
2.4 Proposed Methodology 25
2.4.1 Preprocessing 26
2.4.2 Barcode decoding 26
2.4.3 Barcode displaying 27
2.5 Communication in industry 28
2.5.1 Communication Modbus 28
Trang 122.5.2 Profibus Communication 30
CHAPTER 3 DESIGN CALCULATIONS 32
3.1 Design requirements 32
3.2 System block diagram design 32
3.2.1 System block diagram 32
3.2.2 Working principle 33
3.3 Design each block 33
3.3.1 Central processing unit 34
3.3.2 Executive block 35
3.3.3 Signal block 43
3.3.4 Power block 44
3.4 Calculation of 3-axis X-Y-Z mechanism 45
3.5 Method of learning points in PLC 46
3.6 Design software 48
3.6.1 Algorithm Flowchart 49
3.6.2 Introduction to programming languages and software 51
3.7 System connection diagram 53
3.7.1 General circuit layout 53
3.7.2 Circuit layout to connect driver to PLC and motor 53
CHAPTER 4 RESULT 54
4.1 Results 54
4.1.1 Construction of mechanical parts 54
4.1.2 Electrical cabinet results 60
4.1.3 Display 61
4.2 Experiment 61
4.2.1 The object lies upright, in the middle of the conveyor belt 62
4.2.2 The object lies upright, to the right of the conveyor belt 62
4.2.3 The object lies diagonally, in the middle of the conveyor belt 63
Trang 134.2.4 The object lies diagonally, in the middle of the conveyor belt 63
4.3 Experiment result table 64
4.4 Review and evaluation 64
CHAPTER 5 CONCLUSION AND DEVELOPMENT 66
5.1 Conclusion 66
5.1.1 Pros 66
5.1.2 Cons 66
5.2 Development 67
REFERENCES 68
Trang 141
FIGURES
Figure 2 1 Classification of ripe tomatoes using image processing 9
Figure 2 2 Image processing technology 9
Figure 2 3 Description Pixel 10
Figure 2 4 Gray level range 11
Figure 2 5 Low and high resolution difference 11
Figure 2 6 Function image representation 12
Figure 2 7 OpenCV library logo 13
Figure 2 8 Gaussian filter with multiply size (5.5) and (11,11) 14
Figure 2 9 Illustrate dilation 15
Figure 2 10 Corrosion Magic Illustrated 16
Figure 2 11 Contour illustration 16
Figure 2 12 Approximation algorithm contour illustration 18
Figure 2 13 barcode component 19
Figure 2 14 GS1 barcode 21
Figure 2 15 NW-7 barcode 21
Figure 2 16 CODE39 barcode 22
Figure 2 17 CODE128 barcode 22
Figure 2 18 GS1 databar 22
Figure 2 19 Flowchart of Our Proposed Method 27
Figure 2 20 Communication in industry 28
Figure 2 21 Communication Modbus 29
Figure 3 1 System block diagram 32
Figure 3 2 Types of PLCs available today 34
Figure 3 3 Siemens PLC S7-1200 35
Figure 3 4 NEMA17 stepper motor 42x42x48 37
Figure 3 5 Stepper motor pinout 37
Figure 3 6 JGB37-3530 DC motor 39
Trang 152
Figure 3 7 Driver TB6600 40
Figure 3 8 Electromagnet 41
Figure 3 9 Relay Omron MY2N-GS DC24V 42
Figure 3 10 8 pins intermediate relay pin diagram 42
Figure 3 11 Camera HIKVISON DS-U02 43
Figure 3 12 Omron SS-5GL2 limit switch 43
Figure 3 13 24V honeycomb power 44
Figure 3 14 MCB CHINT NXB-63 45
Figure 3 15 learn points PLC 47
Figure 3 16 System Process Flowchart 48
Figure 3 17 Object identification flowchart 50
Figure 3 18 General circuit layout 53
Figure 3 19 Circuit layout to connect driver to PLC and motor 53
Figure 4 1 Complete system model from top to bottom (1) 55
Figure 4 2 Complete system model from top to bottom (2) 55
Figure 4 3 Complete system model from top to bottom 3D design 56
Figure 4 4 Object recognition structure 56
Figure 4 5 Conveyor structure (1) 57
Figure 4 6 Conveyor structure (2) 57
Figure 4 7 Conveyor structure 3D design 57
Figure 4 8 Object moving structure 58
Figure 4 9 Object moving structure3D design (1) 59
Figure 4 10 Object moving structure 3D design (2) 59
Figure 4 11 Complete electrical cabinet 60
Figure 4 12 Control interface 61
Figure 4 13 Case 1 result 62
Figure 4 14 Case 2 result 62
Figure 4 15 Case 3 result 63
Figure 4 16 Case 4 result 63
Trang 163
ACKNOWLEDGMENT
During the process of implementing the thesis topic, although facing many difficulties, but with timely help and support from the teachers and classmates, the thesis was completed on schedule The team would like to sincerely thank Mr Tran Vi
Do, the instructor, who enthusiastically guided and helped me throughout the implementation process as well as giving me advice, directions and solutions for the topic At the same time, the team would also like to thank the teachers in the Faculty
of High Quality for facilitating in terms of hardware equipment and software knowledge, providing the team with the basic and necessary knowledge to carry out the project as well as perfect the product
Thank you to the classmates of 18146CLA and the students in the thesis group for always being there and helping the group, going through the joys and difficulties during the learning process Everyone's sharing and contributions are always extremely valuable lessons so that the group can complete the project on time
Although the team itself has tried to complete the project report, in the construction process there are many drafting errors as well as limited knowledge, so there may be many shortcomings The group looks forward to receiving comments from teachers and students
Finally, the team would like to wish you good health, success and continue to train good students to contribute to the country Thank you sincerely
Students who did the project
LE NGUYEN ANH KHOA BUI DINH NAM THANH TANG HOANG LONG
Trang 17ABSTRACT
The product classification system by barcode is a combination model of programmable control (PLC) combined with image processing capable of automatically detecting and classifying samples according to product barcodes The thesis consists of 2 parts: Building a mechanical model operating in 3 stable X-Y-Z axes, designing a system to automatically detect and process images on barcodes and position for mechanical classification models
After recognizing the barcode and the position of the object on the conveyor belt by the experimental image processing algorithm to achieve relative accuracy The lead screw mechanism and the electromagnet will receive a signal from the PLC to bring the product into the specified lane However, the system sometimes works is still unstable due to the influence of some factors such as natural light causing the shadow
of the object, causing the barcode recognition and the position to be not completely accurate
Finally, students use Visual Studio Code software to program image processing programs based on Python programming language on OpenCV open-source library that can communicate with PLCs As a result, a product classification system based on barcodes and communication with PLCs works in accordance with the requirements
Trang 18CHAPTER 1 OVERVIEW OF THE TOPIC
1.1 Question
Up to now, the automation system and the role of automation have become very great in the construction and development of the country in general as well as in the development of enterprises in particular The application of technology to the factory's production lines as well as other operations of the factory helps to create closed, safe and quality implementation processes
In production sorting lines, for instance, shipping companies, it is essential to check the product’s name and its’ delivery location to ensure that the product is delivered to the right ordering person For example, classify the products in groups of districts; classify the products into their categories
For manual lines, workers use their eyes to check and find out the product’s location However, in a modern production line, it is required to produce a large quantity in a short time, and the requirements for accuracy are for product quality At that time, on the production line, the product must move at a very fast speed, moreover, there are very small products that the human eye cannot meet Therefore, it is extremely necessary to automate the inspection process instead of humans
A product sorting machine using barcode technology can be designed to increase efficiency and accuracy in sorting products Here are some potential benefits:
Increased speed and efficiency: With a barcode sorting machine, products can be sorted much faster than manual sorting The machine can read the barcode and sort the product into the correct category automatically, saving time and reducing the likelihood of human error
Improved accuracy: Barcode technology is highly accurate and can help ensure that products are sorted into the correct category every time This can reduce the risk of errors and save money by reducing the need for manual sorting and handling
Better inventory management: By using barcode technology to sort products, the machine can also track inventory levels and provide real-time
Trang 19data on stock levels This can help businesses to manage their inventory more efficiently, reducing waste and improving profitability
Increased customer satisfaction: A product sorting machine can help businesses ensure that orders are fulfilled accurately and on time This can improve customer satisfaction and help businesses to retain their customers
1.2 Object of the research
The goal of the project is to design, program and operate the project "Design and construction of a product classification system" based on algorithms for detecting object barcodes, calculating the center of objects using Python language based on OpenCV open-source library
Use and program PLC proficiently, apply its functions to apply to the system Identify the barcode, the location of the product From there, it is possible to accurately classify products and put them in the lanes according to the original regulations
1.3 Research method
Refer to the documentation on the home page http://www.siemens.com combined with direct practice on the Siemens 1214 CPU on the model
Refer to some documents on related forums
Survey some real models and some topics first
1.4 Research content
The topic covers the stages from design to successful building of the model, detailing the stages of model building from the process of understanding how the system works to mechanical design Provide a plan for selecting and connecting control and monitoring devices, system control algorithms The topic also gives comments, evaluates the achieved results and analyzes the limitations to provide solutions and develop the topic in the future The rest of the thesis has the following content:
Chapter 1: Overview of the topic: Presenting a preliminary overview of the
initial proposals of the topic, including the problem statement, the topic's objectives, the research content and the topic's limitations
Trang 20Chapter 2: Theoretical basis: Presenting possible solutions for the design and
construction of the system
Chapter 3: Design calculations: From the design requirements and control
requirements of the topic, make design calculations and select system hardware devices
Chapter 4: System construction: Carrying out the construction and assembly
of the designed model; provide algorithm flowchart and control programming, system operation
Chapter 5: Results, comments and evaluation: Presenting the results of the
overview of the topic, what has been studied, comments and evaluation of the results
Chapter 6: Conclusions and directions for development: Presenting the
results achieved Evaluate the advantages, disadvantages and difficulties encountered during the implementation of the thesis Proposing ideas to improve shortcomings and future development orientations
1.5 Research limit
The topic focuses on researching and designing a stage in an industrial automatic production line After the product is completed, it will be classified and taken to the place where the next stages of the work are performed Currently, in factories and enterprises, there are many complete systems in both quality and aesthetics However, within the scope of a research topic, the topic is limited by:
The system only classifies the trait as a barcode: The object of the classification is the product with the barcode and the size selected by the student
In a single scan, each image processing algorithm barcode can only recognize one object
Supervisory control capabilities are limited to a small range
Average processing speed
Trang 21CHAPTER 2 THEORETICAL BASIS
2.1 Overview of product categories
The product sorting system is an industrial solution that replaces humans to complete the product sorting process, from manual implementation to the use of automated systems to divide products according to each characteristic specified user
A complete system capable of sorting products with high reliability, continuous operation and minimal system downtime In addition, for jobs that require high concentration and continuous circulation, it is difficult for workers to ensure accuracy
in work That directly affects the product quality and the manufacturer's reputation Some of the currently applied product classification systems are: Product classification based on barcode - height - weight, product classification based on barcode scanners, product classification for image processing,
2.1.1 Methods of product classification
For systems using supporting devices such as color sensors, optical sensors, barcode readers, etc., there are advantages: easy programming, fast processing speed, easy operation, However, they also have some disadvantages: barcode scanning can
be more labor intensive, time is not high, it can only recognize a single product by barcode, barcode or height, but cannot receive power at the same time the above factors
2.1.2 Product classification applied image processing
The great advancement in image processing has opened a new step in product classification Applying image processing not only overcomes the shortcomings of the old product classification system, but also has high synchronization, it is possible to convert classified products according to the program In addition, it saves investment
costs because many properties can be integrated in a single processing program
Trang 22Figure 2 1 Classification of ripe tomatoes using image processing
2.2 Overview of image processing
Image processing is a science and technology field, a new science compared to many other sciences, but its development speed is very fast This stimulates research and application centers, especially dedicated computers dedicated to it
This is a technique to enhance and process images received from devices such as cameras, webcams, Therefore, image processing has been used and strongly developed in important areas such as:
Military: recognition and image processing in remote sensing, radar,
Figure 2 2 Image processing technology
Trang 23satellite,
Security and privacy: recognition of signatures, fingerprints, faces,
Entertainment: video games, making actual games more entertaining
Medical: X-ray images, biomedical, MRI,
2.2.1 Concepts of image processing
2.2.1.1 Digital photo
An image is defined as a two-dimensional function (F(x, y)), where x and y are the spatial coordinates, and the amplitude of F at any pair of coordinates (x, y) is called the intensity of that image at that point When the x, y and amplitude values of F are finite, we call it a digital image In other words, an image can be identified by a two-dimensional array specifically ordered by rows and columns A digital image consists
of a finite number of components, each of which has a specific position and value These components are called pixels
2.2.1.2 Pixel
The process of digitizing an image transforms from an analog value to a digital one and quantizes a value that in principle cannot distinguish two adjacent points with the naked eye In the past, this process uses the concept of Picture Element, which we often call Pixel – 12 image elements, pixels Thus, the image is a collection of pixels Each Pixel consists of a pair of x, y and color coordinates
A Pixel is usually represented by 1, 2, 8 or 24 bits of color
2.2.1.3 Gray level
Figure 2 3 Description Pixel
Trang 24The gray level is the result of the corresponding transformation of a pixel's luminance value with a positive integer value Usually, it is specified in the range [0, 255] depending on the value that each pixel is represented Common gray level values are 16, 32, 64, 128, 256 (common because computer engineering uses 1 byte = 8 bits
to represent gray levels, gray levels use 1 byte to represent 28 = 256 values value from
0 to 255)
2.2.1.4 Image resolution
Image resolution is the pixel density assigned to a displayed digital image The distance between pixels must be chosen so that the human eye can still see the continuity of the image The selection of the appropriate distance creates a distribution density that is the image resolution and is distributed along the Ox (horizontal) and Oy (vertical) axes in two-dimensional space The higher the resolution of the image, the smoother and clearer the transformations in the image will be
Figure 2 5 Low and high resolution difference
2.2.2 Basic problems in image processing
2.2.2.1 Photo show
To represent images, people often use the feature elements of the image as pixels (pixels) Therefore, we can represent the image by a function of two variables containing the information Image representation models give a logical or quantitative
Figure 2 4 Gray level range
Trang 25description of the properties of this function Image quality or the effectiveness of processing techniques depends on many factors such as image resolution, noise, etc
Figure 2 6 Function image representation
2.2.2.2 Image transformation
Transforming the representation of images under different viewing angles is convenient for image processing and analysis Commonly used methods: Fourier transform, Sine, Cosine
2.2.2.3 Photo analysis
In the image processing process, the extraction of features from the objects in the image is a very important step The properties of the object are extracted during processing depending on the recognition purpose, making the recognition more accurate, speeding up the computation time and reducing the storage space Some of the features include:
Spatial features: probability distribution, gray level distribution, inflection point, image amplitude,
Boundary - boundary feature: useful for analyzing invariant properties used to identify objects (angles, edges) To get the edge image we can use Gradient operator, Canny algorithm, Laplace operator
Transform features: features of this type are extracted by performing area filtering Area filters called "feature masks" are mainly narrow slits with various shapes (circle, rectangle, square, ellipse)
Trang 262.2.3 OpenCV library and image processing methods used in the project 2.2.3.1 Open-Source library OpenCV
OpenCV is the leading open-source library in the fields of computer vision, image processing and machine learning It was released in 1999 under the BSD license (a group of permissive free software licenses), so it's completely free for both academic and commercial use Supports programming languages C++, C, Python, Java and Windows, Linux, MacOS, iOS and Android operating systems OpenCV is written in
C / C ++ language so it has very fast computation speed, focusing heavily on real-time applications Popular applications in image recognition and processing, automatic inspection and monitoring, Robots and autonomous vehicles, medical image analysis, virtual reality
Some outstanding features included in OpenCV library include: toolkit to support 2D and 3D image processing; Face Recognition; object recognition; gesture recognition; object movement and behavior recognition; human-computer interaction; control the Robot; virtual reality technology support
Figure 2 7 OpenCV library logo
2.2.3.2 The image processing methods used in the project
Image smoothing
As with any other signal, images can also contain various types of noise, especially due to the source (camera sensor) Smoothing, also known as blurring, is one of the most common image processing operations used to reduce noise in images In this topic, students will choose a Gaussian filter to blur the input image
The Gaussian filter has the property that there is no excessive step function input in while minimizing rise and fall times In terms of image processing, any sharp edges in
Trang 27the image are smoothed out while minimizing excessive blur It uses a Gaussian kernel with a user-selectable size, but the height and width of the kernel must be odd The filter converts all pixels in the image into a new set of pixels with the new value being the weighted average of the pixel's color values in the calculated kernel
Figure 2 8 Gaussian filter with multiply size (5.5) and (11,11)
Dilation
Dilation is the convolution of images (or image areas), we call them A, with a multiplier we call them B The kernel can have many different shapes and sizes, but only there is a point called a single anchor point Usually, the kernel is a small square
or disc-shaped block with a central anchor point The kernel can be identified as a pattern or a mask, and what it means in the dilation algorithm is to locate the element with the maximum value When multiply B is scanned over the entire image, we calculate the maximum pixel value of the image area matched by the B kernel and replace the pixel specified by the anchor point with the calculated maximum value This causes the bright areas of the image to expand It is this expansion that is the origin of the term "expansion process"
The dilation on the binary image is described by the following mathematical expression:
A ⊕ B = {c | c = a + b, a ∈ A, b ∈ B} (2.1)
In which:
- A: The pixel matrix of the binary image.F
- B: Structure element
Image dilation will produce a set of pixels c belonging to D(i), we see that this
is a sum between A and B, A will be a subset of D(i)
Trang 28Figure 2 9 Illustrate dilation
Erosion
Erosion is the reverse process of expansion The behavior of the erosion operator
is equivalent to locating the minimum value of the luminous intensity on the region corresponding to the input convolution kernel Erosion creates a new image from the original image using the following algorithm: when multiplying B scans the entire image, we compute the pixel with the smallest value matching B and replace the image pixel value specified by the anchor point with the minimum value (for accuracy, the pixel on the output image will set the value equal to the minimum value of the pixels initialized by the multiplication on the input image)
Erosion is described by the following mathematical expression:
Trang 29 Contour
Contour can be simply explained as a curve joining all the continuous points (along the boundary), having the same color or intensity Contours are a useful tool for shape analysis, object detection and recognition
Moment
Image Moment is a set of statistical parameters to measure the position distribution
of pixels and their intensities Mathematically, the Image Moment M ij of the order (i, j) for a grayscale image with pixel intensity I(x, y) is calculated by the following formula:
To find the center, we calculate the average of the positions of all the points,
Figure 2 10 Corrosion Magic Illustrated
Figure 2 11 Contour illustration
Trang 30with the formula:
M10 and M01 are the values calculated in terms of x and y, respectively,
so that when performing the math, we can reduce the intensity of the measured pixels to be equal
If the distance from C to AB is less than ε, the point C will be removed from the Contour, otherwise if it is greater than or equal to ε, the point C will be kept and the Contour will be divided into 2 straight segments, AC and CB
For each segment AC and CB, the algorithm will be repeated in the same way as with the original AB
Trang 31The Approximation algorithm is often used to determine the correct and clear shape of objects that can be of basic shapes such as quadrilaterals, triangles, even circles,
2.3 Overview of Barcode detection
2.3.1 Barcode
2.3.1.1 Barcode Overview
A barcode is “A machine- readable code in the form of figures and a pattern of resemblant lines of varying extents, published on and relating a product” A barcode can best be described as an “optic Morse code” Series of black bars and white spaces
of varying extents are published on markers to uniquely identify particulars The barcode makers are read with a scanner, which measures reflected light and interprets the code into figures and letters that are passed on to a computer Because there are numerous ways to arrange these bars and spaces, multitudinous symbolisms are possible But in verity a barcode is so much more Barcode systems help businesses and associations track products, prices, and stock levels for centralized operation in a computer software system allowing for inconceivable increases in productivity and effectiveness There are two types of barcodes direct – or 1D, and 2D Mostly recognizable barcode visually, the UPC (Universal Product Code) is a linear 1D barcode which consists of two parts the black and white pattern recognized as barcode
Figure 2 12 Approximation algorithm contour illustration
Trang 32and the 12- digit UPC number The first six integers of the barcode represent the pattern as well as the manufacturer’s identification number The coming five integers represent the item’s number The last number is nominated as a check number which helps the scanner to determine if the barcode being scrutinized is free of error
A barcode’s density is determined by the “X ” dimension Density refers to the quantum of information that can be acquired in the bar code in a particular space, generally a direct inch While not intimately egregious, high density bar codes have low figures and low- density bar codes have high figures This is because individual characters correspond of some combination of bars and spaces that are each multiple
of “X ” When “X ” is small, the area needed for each character is lower than when “
X ” is large; therefore, the bar code can hold further per direct inch and is said to be of advanced density also, adding the range of the narrowest element (X) increases the space needed for each character and reduces the number of characters per inch Because the performing code is frequently relatively large, veritably low- density codes are frequently associated with operations similar as warehousing that bear reading bar codes from a significant distance (3 to 30 bases)
2.3.1.2 Barcode components
Figure 2 13 barcode component
①Quiet Zone (margin)
Quiet Zone is a blank margin located at either end of a barcode The
Trang 33minimal margin between barcodes (distance from the outermost bar of one barcode to the outermost bar of another barcode) is 2.5 mm If the width of a Quiet Zone is insufficient, barcodes are hard for a scanner to read
②Start Character/Stop Character
The Start Character and the Stop Character are characters representing the start and the end of the data, respectively The characters differ depending on the barcode type
③Check Digit (Symbol check character)
The Check Digit is a digit for checking whether the encoded barcode data are correct
2.3.2 Barcode types
2.3.2.1 1D Barcode font Common product codes
Common product codes are broadly divided into two groups: UPC and EAN
・UPC = Universal Product Code
Common product code standardized in the U.S
・EAN = European Article Number
Common product code standardized in Europe based on UPC
In Japan, as a kind of EAN, JAN (Japanese Article Number) is used EAN (JAN) consists of 13 digits in the standard version and 8 digits in the shortened version UPC consists of 12 digits and 7 digits (including the check digit) in the standard and shortened versions, respectively EAN/UPC has been standardized as an ISO standard (ISO/IEC15420) and a JIS standard (JISX0507) In Japan, JAN codes are affixed to food, sundry articles, etc and are mainly used in Point Of Sales (POS) systems
The composition of a common product code is common in all countries, and a country code has been assigned to each country
Trang 34For example, "49" and "45" are assigned to Japan
GS1 Company Prefix
Code obtained by each manufacturer by application to the Distribution Systems Research Institute (GS1 Japan) via the Chamber of Commerce and Industry of each municipality/prefecture
Figure 2 14 GS1 barcode
Product Item Code
Code determined by each manufacturer, similar to a product code
Trang 35(e.g., container boxes) and for small labels affixed to noble metal and small products
It was standardized as a distribution product barcode symbol (JIS-X-0502) in 1987 and
as JIS (JISX0505) in 2004
CODE39
CODE39 enables the representation of alphabetical characters, and has been adopted as a military standard of the U.S Department of Defense (MIL-STD) It is widely used in the factory automation (FA) field and for AIAG, ODETTE and EIAJ tags Data that can be encoded are numerals (0 to 9), symbols ("-", " " (space), "$", "/",
"+", "%" and ".") and alphabetical letters (A to Z)
Figure 2 16 CODE39 barcode
CODE128
CODE128 can encode all 128 characters of ASCII It is used mainly in the factory automation (FA) and office automation (OA) fields Data that can be encoded are all
128 characters of ASCII It comprises three code sets
Figure 2 17 CODE128 barcode
GS1 Databar
GS1 Databar has three types of seven symbols GS1 Databar can represent data in
a smaller area than existing barcodes By using Application Identifiers (AIs), which are standardized by the GS1 Japan, information on product attributes, including expiration dates and lot numbers, can be represented In 2015, labeling GS1 Databar symbols on all ethical pharmaceuticals was made obligatory
Figure 2 18 GS1 databar
Trang 362.3.2.2 2D Barcode font PDF417
Large amounts of text and data can be stored securely and inexpensively when using the PDF417 barcode symbology The printed symbol consists of several linear rows of stacked codewords Each codeword represents 1 of 929 possible values from one of three different clusters A different cluster is chosen for each row, repeating after every three rows Because the codewords in each cluster are unique, the scanner is able
to determine what line each cluster is from
Figure 3.9: PDF417 barcode
Data Matrix
Data Matrix is a very efficient, two-dimensional (2D) barcode symbology that uses
a small area of square modules with a unique perimeter pattern, which helps the barcode scanner determine cell locations and decode the symbol Characters, numbers, text and actual bytes of data may be encoded, including Unicode characters and photos
Figure 3.10: Data Matrix
Maxicode
Maxicode is an international 2D (two-dimensional) barcode that is currently used
by UPS on shipping labels for world-wide addressing and package sortation MaxiCode
Trang 37symbols are fixed in size and are made up of offset rows of hexagonal modules arranged around a unique finder pattern MaxiCode includes error correction, which enables the symbol to be decoded when it is slightly damaged
Figure 3.11: Maxicode
QR Code
QR-Code is a two-dimensional (2D) barcode type similar to Data Matrix or Aztec, which is capable of encoding large amounts of data QR means Quick Response, as the inventor intended the symbol to be quickly decoded The data encoded in a QR-Code may include alphabetic characters, text, numbers, double characters and URLs The symbology uses a small area of square modules with a unique perimeter pattern, which helps the barcode scanner determine cell locations to decode the symbol
Figure 3.12: QR Code
2.3.3 Pyzbar Detection
Read one-dimensional barcodes and QR codes from Python 2 and 3 using the zbar library
Trang 38 Pure python
Works with PIL / Pillow images, OpenCV / imageio / numpy ndarrays, and raw bytes
Decodes locations of barcodes
No dependencies, other than the zbar library itself
Tested on Python 2.7, and Python 3.5 to 3.10 The older Zbar package is stuck in Python 2.x-land The Zbarlight package does not provide support for Windows and depends upon Pillow
2.3.3.1 ZBar versions
Development of the original Zbar stopped in 2012 Development was started again
in 2019 under a new project that has added some new features, including support for decoding barcode orientation At the time of writing this new project does not produce Windows DLLs The Zbar DLLs that are included with the Windows Python wheels are built from the original project and so do not include support for decoding barcode orientation If you see orientation=None then your system has an older release of Zbar that does not support orientation
2.3.3.2 Quality field
From zbar.h, the quality field is an unscaled, relative quantity: larger values are better than smaller values, where “large” and “small” are application dependent Expect the exact definition of this quantity to change as the metric is refined currently, only the ordered relationship between two values is defined and will remain stable in the future
Trang 39In shopping system, it is observed that there is a laser scanner for detecting barcodes from a product But if there are multiple products, then the system needs more time to detect many products And it is tough to detect multiple product barcodes one
by one at a time So, our method is helpful for solving this issue so that it takes less time in shopping system to detect all the barcodes This proposed method is to detect multiple 1D and 2D barcodes from a snap EAN-13, Code 128 as 1D barcode and QR Code as 2D barcode were used For the detection of the barcodes, two steps were followed They are:
To find the position of a barcode
To decode the barcode
Once an image is obtained, the first step is to localize the barcode, or to find its location within the image Many methods to do this have been developed Again, after the barcode is localized using one of the methods in the previous section, it must be decoded in order to obtain the product’s information These processes were achieved
by the usage of Python language Firstly, an algorithm was processed to detect the barcode from the snap, then the job of decoding comes And the main benefit in this process is, detecting multiple barcodes at a time and detection of the barcode of cylindrical objects too attainable We have used OpenCV and Pyzbar library to detect and decode the barcodes from the snap There are three main methods of this proposed
barcode detection and decoding process They are: Preprocessing or Localizing,
Barcode decoding and Barcode displaying
2.4.1 Preprocessing
After taking an image as input, preprocessing is required this is just like resize the image, filtering the image Initially image had the resolution of 3146X3146 pixels which was reduced to 528X704 pixels The image is converted to grey scale image Then converted to Pyzbar compatible format to find image symbols
2.4.2 Barcode decoding
In this stage, the Pyzbar library decodes the barcode In the preprocessing stage image is already in ZBar compatible format Then scanlines are used to iterate over the symbols to extract type, data and location information
Trang 402.4.3 Barcode displaying
After decoding next step is displaying the symbols A quad is formed outside the barcode while displaying 2D barcode image If location is not a quad an outer boundary box is drawn
Figure 2 19 Flowchart of Our Proposed Method