Lesson 6: Self-service Cashier with an AI Machine Vision Sensor
In our daily life, we often need to go to the supermarket for shopping. However, the problem of queuing for checkout after shopping can bring us quite a bit of trouble, especially when we buy a large number of goods.
With the advancement of technology, self-checkout machines have already appeared in many supermarkets, bringing convenience to our shopping experience. Now, we will combine the micro:bit and AI Machine Vision Sensor to develop an innovative supermarket self-checkout system.
his system will be able to automatically identify and calculate the prices of goods, thereby improving checkout efficiency and reducing queuing time.
Learning Objectives
1. Learn the working principle and application field of barcode.
2. Learn to use the barcode recognition function of AI machine vision sensor HUSKYLENS.
3. Use the barcode recognition of AI machine vision sensor HUSKYLENS to make a self-service supermarket cashier.
Preparation
Learning Content
If we have a close-up view on the process of check-out, we will find whether it is a manual or self-service cashier, it’s all the same: scan the barcode of the product and calculate the bill. As the barcode of each product is different, we only need to find replacements for code scanner and barcode to realize our project.
Scanning devices-----the tag recognition function of AI machine vision sensor HUSKYLENS
Barcodes-----Any Tags
Working Principle and Application Field of Barcode
1. What is barcode technology?
Bar code is a symbol that expresses certain information composed of a group of bars, spaces and their corresponding characters arranged in a regular manner. Different code systems have different composition rules for bar code symbols. At present, the more commonly used code systems are EAN barcode, UPC barcode, 2/5 barcode, interleaved 2/5 barcode, Codabar, 93 barcode, 128 barcode and so on.
Barcode technology is an emerging technology that integrates coding, printing, recognition, data collection and processing developed on the basis of Computer Information Technology. The core content of bar code technology is to use photoelectric scanning equipment to read bar code symbols, so as to realize the automatic recognition of the machine, and quickly and accurately input the information into the computer for data processing, in order to achieve the purpose of automatic management.
2. Working principle of barcode technology
The barcodes compiled according to certain rules need to go through the processes of scanning and decoding to be converted into meaningful information. The color of an object is determined by the type of light it reflects. A white object can reflect various wavelengths of visible light, and a black object can absorb various wavelengths of visible light.
Therefore, after the light emitted by the light source of the barcode scanner is reflected by the barcode, the reflected lights shine over the photoelectric converter inside the barcode scanner, and the photoelectric converter converts the reflected light signal into corresponding electrical signal according to the different intensity of the reflected light signal.
3. Application field of barcode technology
Retail Industry
The most common use of barcodes is in the retail industry. EAN commodity barcodes build the foundation for the retail industry to apply barcodes. At present, most of the commodities sold in supermarkets use EAN barcodes. When selling, the cashier scans the EAN barcodes with a scanner. The POS system finds the corresponding name, price and other information from the database, and counts the commodities purchased.
Library
Barcodes are also widely used in the circulation of books in libraries. Barcodes are affixed to books and library cards. When borrowing books, you only need to scan the barcode on the library card, and scan the barcode on the book, then the relevant information will be automatically recorded in the database.
Warehouse Management and Logistics Tracking
For the occasion of the mass flow of commodity goods, the application of barcode technology can realize fast and accurate recording of each item, and the various data collected can be processed by the computer system in real time. This enables various statistical data to accurately and timely reflect the status of items.
Can you find other applications of Barcode in daily life?
Demonstration of AI machine vision sensor HUSKYLENS Barcode Recognition Function
1. Detect barcode
When detected by AI machine vision sensor HuskyLens, all of the barcodes will be selected by orange frames on the screen automatically.
Note: When AI machine vision sensor HUSKYLENS learns and recognizes barcodes, the ambient light may affect the recognition result. In order to improve accuracy, it is recommended to put a piece of white paper under the paper cards.
2. Learn barcodes
Now, learn and recognize the following three paper cards. (Note: The barcode on the front and back is the same).
Point the "+" symbol at the barcode, long or short press the "Learning button" to complete the first barcode learning. After releasing the "Learning Button", the screen will display: "Press the button again to continue! Press other buttons to end. " To continue learning the next barcode, press the "Learning button" before the countdown ends. If you no longer need to learn other barcodes, press the "Function button" before the countdown ends, or do not operate and wait for the end of the countdown.
In this project, we are going to learn multiple barcodes. Therefore, we need to short press the “Learning Button” before the countdown ends. Then, point the “+” at the second barcode, pressing or holding the “Learning Button” to complete this learning, and so on.
The tag ID is in the same order as the tag entered. That is, the learned tags will be tagged "Tag: ID1", "Tag: ID2", "Tag: ID3", and so on. Moreover, different tags correspond to different frame colors.
3. Recognize barcodes
When the AI machine vision sensor HUSKYLENS encounters the learned barcodes again, there will be a colored frame to select them and display their IDs on the screen. The size of the frame can change with the size of barcodes and track barcodes automatically.
AI vision Project Practice
We will finish the project in two tasks. Firstly, use the barcode recognition function of HUSKYLENS to learn and recognize three products with barcodes, and then display the price on the AI machine vision sensor HUSKYLENS screen.
Secondly, based on the previous step, add the start and end of the scanning code events to perform quantity statistics of customer’s products. At last, add the total price settlement function to realize the supermarket self-service cashier function.
Task1: Price displaying
Let AI machine vision sensor HUSKYLENS learn and recognize the barcodes of three different products. Write a program to make HUSKYLENS display the prices of the successfully recognized product on the screen.
Task 2: Price settlement
Based on task 1, add the product price settlement function. When any learned product is recognized, the price of a single product will be added to the total price.
Task1: Price displaying
Hardware connection
AI Vision Program Design
Function instruction:
There are various products in the supermarket, and each one has a corresponding barcode and price. Now let HUSKYLENS learn three products in turn: fruit, candy, and toy. Assuming that the price of each product is: fruit (7 yuan), candy (4 yuan), toy (15 yuan), display the corresponding price of each product on the AI machine vision sensor HUSKYLENS screen.
Flowchart analysis
The MakeCode Sample Program
Makecode Sample Program link :https://makecode.microbit.org/_08tVqgXk57rA
AI Vision Project Operating Effect
When the barcode is successfully recognized, the buzzer on the IO expansion board will emit a mid-tone Do, and the corresponding price of the product will be displayed on the AI machine vision sensor HUSKYLENS screen.
In this project, the buzzer that comes with the IO expansion board is used to indicate the success of the scanning, so you need to turn the switch of the buzzer to the playback position.
Task2: Price settlement
Hardware connection
AI Vision Program Design
Function instruction:
How can we make sure that the total price is that of the goods we bought? Use the state of the Bistable LED Switch to control!
The customer presses the button for the first time (the state of the bistable switch is: 1), scanning starts, and the recognized product name is displayed on the AI machine vision sensor HUSKYLENS screen; press the button again (the state of the bistable switch is: 0), When the scan is finished, the total price of the scanned product will be displayed on the AI machine vision sensor HUSKYLENS screen. After the scan is completed, any product scanned by the same customer will not be displayed. The next customer presses the button to restart the scan.
Flowchart analysis
The MakeCode Sample Program
Makecode Sample Program link :https://makecode.microbit.org/_Y79PKxJPCLAm
Note: The LED Switch is connected to the P1 pin of the IO expansion board in the project, so reading the digital value of the P1 pin is to get the state of the LED Switch.
Operating Effect
Press the switch, the LED light of the button is on, and you can start to scan the barcode of the products. After the barcode is successfully recognized, the corresponding product price will be displayed on the screen; press the switch again, the LED light of the button is off, and the scan ends, the total unit price of the scanned products will be displayed on the screen.
Project Review
This project mainly uses barcode recognition technology to recognize the corresponding product information and output a specific ID so as to display the product prices on the AI machine vision sensor HUSKYLENS screen and realize the function of settlement. Now the supermarket self-service cashier system is basically done.
Project Development
Normally, there is a locker for free storage at the entrance of the supermarket. Before storing things, press the "Store" button, the locker will print a barcode, and the corresponding locker will automatically open when you get the barcode. Can you use the AI machine vision sensor HuskyLens to complete the locker project?
Click Buy Study Pack of HUSKYLENS for micro:bit
Click Buy Huskylens - An Easy-to-use AI Camera | Vision Sensor
Click Buy Study Pack with HUSKYLENS and micro:bit V2
Engage in learning the next AI vision project : Energy Harvest with an AI Machine Vision Sensor
Engage in learning the previous AI vision project : Object Tracker with an AI Machine Vision Sensor