How To Scan QR Codes With A Raspberry Pi + OpenCV + Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey gang tim here at grow electronics and today we're using our raspberry pi single ball computer to actively search identify and record the data of any qr code then we'll go a step further and activate gpio pins using the specific qr codes qr quick response codes are absolutely everywhere in our modern world and for great reason sharing a lot of similarities to barcodes but instead of a laser a camera is used to identify the spaces between the black and white square markings encoding data in this way is incredibly useful and with machine learning it has never been easier to decode their secrets there are lots of standards and types of qr codes but this system will work with all common types creating custom codes is easy for example on screen right now i'm creating one using the qr code generator website link to it down below any queue i made here is going to be readily decoded by our raspberry pi system that we're making right now for our raspberry pi system to work we're going to incorporate the incredible opencv software to our code opencv is a huge resource that helps solve real-time computer vision and imaging processing problems its purpose here is to find those qr codes here on the table is everything you need to start decoding these mysterious qr codes naturally you're going to need a camera i'm going to be using the high quality camera module with a five millimeter lens but you can definitely use the raspberry pi official camera module version 2 for this purposes i'm using here a raspberry pi 4 model b that extra power that these have are very valuable for computer vision systems like the one we're building towards here you're also going to want a micro sd card that's been flashed with raspberry pi os that has been connected to the internet is fully updated and has the camera enabled inside the settings we have also installed a number of packages to the raspberry pi os through five terminal lines that can be found in the article and description below these and the normal power supply hdmi cord monitor and peripheries combo and you'll be good to go so plug in that micro sd card the mouse the keyboard and the monitor and then connect the ribbon cable to the csi camera serial interface connector on the raspberry pi board to connect the ribbon cables lift up the edges of the csi connector gently slip the ribbon cable in until it bottoms out and then push down the edges of the csi connector with that all done provide power to the system by plugging in the usb-c port which will start the booting process once the booting sequence is completed you will be welcomed with the raspberry pi os now i've created three codes to do the qrd coding and i have fully commented each so for those curious to see what's happening behind the curtains just simply take a look jump onto the article page linked down below to download all of these codes with them downloaded unzip the contents onto your raspberry pi desktop the first one to check out is the simplest one named qr simple code all you need to do is right click it and open it up using thony ide or any python interpreter that you would like then with the code open run it by pressing the big green run button and as soon as you run the code you're going to see it actively search for qr codes when it finds a qr code like some of these on here you're going to see that it captures the data and will write it directly into the shell of funny as well as on the live stream the next code to check out is the qr simple code with csv you're going to open it up in the same way as before and this code does exactly what was happening before except this time it's going to take that recorded information and store it into a text file format in a manner which could easily be transferred into excel the format used will be csv comma separated value format and each qr code will have the data date and a time stamp recorded into a text file to capture this information with the code you're going to need a text file named database.csv saved into the same directory in this case here and to our desktop as the code this file is case dependent and if you unzip the download folder this text file will already be there for you the natural next step which is the final code shown here on screen would be to use the qr codes to activate the gpio pins on our raspberry pi in this example if a qr code has embedded into it the data red when the raspberry pi identifies that qr code it's going to light up the red led and respectively the same for the green led when it sees a qr code that says green this has all been done with only nine lines of added code to the first example which you can see here and here now on the table in front of me i have wired up two leds with matching resistors in series for both onto a breadboard and attach the leds to the ground pin and the gpio pin 8 and gpio pin 4 respectively of the raspberry pi so with my qr codes in hand this side with the data red encoded onto it and the other side with green let's run the code and try and light these leds up is it too bright for you oh red and then as soon as that happened the red lit up and red will stay on so now i'm going to turn it around and show it the green value green now on the table here i've controlled some simple leds but understand that these leds are just placeholders for absolutely anything gpio pins are the doorway to controlling almost an endless amount of sensors motors actuators or signals it's up to you and your curiosity to decide what you're going to do with it hopefully this has got you excited to whip up some qr codes tinker with some code and try it out for yourself so until next time stay cozy [Music] you
Info
Channel: Core Electronics
Views: 34,231
Rating: undefined out of 5
Keywords: QR Scanning DIY, Raspberry Pi and Automatic QR Decoding, How to read QR codes with Raspberry PI, Learn how to understand QR Codes, QR Code Recorder machine, Use QR Codes to control GPIO on RASPI, Raspberry Pi QR Codes, Camera Module Raspberry Pi and QR Codes, Raspberry Pi 4 Model B, Raspberry Pi, GPIO Contorl Via QR, Open CV, opencv, open-cv, OpenCV and Raspberry Pi, Machine Learning, HQ Camera Module, Real Time Scanning, Quick Response Codes, AI and single board computers
Id: Qf55aUgfLfQ
Channel Id: undefined
Length: 5min 42sec (342 seconds)
Published: Mon Nov 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.