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

preview_player
Показать описание
All scripts dived into here will display decoded QR data live, one will also capture the information into a text file and the final will use specific QR codes to control the GPIO.

Make sure to use the Previous Raspberry Pi 'Buster' OS with this Guide.

Related Information

Terminal Commands
sudo apt-get update

sudo apt-get install python3-opencv

sudo apt-get install libqt4-test python3-sip python3-pyqt5 libqtgui4 libjasper-dev libatlas-base-dev -y

pip3 install opencv-contrib-python==4.1.0.25

sudo modprobe bcm2835-v4l2

Cameras in combination with machine learning create the most powerful sensor you can ever put on a Raspberry Pi. Open-CV is a huge resource that helps solve real-time computer vision and image processing problems. To install it and the other required packages it is best done by typing and entering the above 5 lines into the Raspberry Pi Terminal. This guide focuses on QR (Quick Response) Codes. These 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 spaces between black and white squares markings. Encoding data 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.

Core Electronics is located in the heart of Newcastle, Australia. We're powered by makers, for makers. Drop by if you are looking for:

0:00 Intro
0:19 QR Code Overview
0:43 Creating Custom QR Codes
0:56 Open-CV
1:10 What You Need and Terminal Commands
1:58 Hardware Build
2:27 Code Download Location
2:44 Simple Code
3:14 Data Record Code
3:55 GPIO Control Code
4:45 The Pay Off
5:06 Where to Now
5:24 Outro
Рекомендации по теме
Комментарии
Автор

I have not been to our makers space for a while (Covid was only part of the reason *sad*) but the boom gate we had was triggered by a pi accessing a remote control button. This could be even better as it could log details of each member. Interesting if you could use one pi to scan then broadcast to another so that the remote can be protected so people don't push the remote button...

DarrylAdams
Автор

Superb, simple and clearly explain videos. Will try it for sure.. start with the pi zero.. hopefully its working. Anyway, hope author can also create content, how to record this qr code into the google sheet. Will be very useful for making attendance for my students. Tq sir

syaduinotech
Автор

Hey, would I be able to connect the cables to the GPIO pins and light up the LEDs without using a breadboard? I only have cables and resistors

brawlstrso
Автор

Hey! great video! just what I needed! all works as showed, however my camera is having a 5 -10 second delay. im using raspberry pi 3B+ (1gb) and rasp pi cam V1.3. What could be the issue, what do you think? Not enough ram?

PusherAtUrDoor
Автор

Thanks for the video. I had a bit of an issue using the buster legacy image from pi imager (released 2022). The installation work but when using it in python (same way as your code), it doesn't work, it returns error : vidioc_qbuf invalid argument. Some sources said to increase gpu mem to 128 or even 144 but that didn't work.

I reinstalled your image (from link) this time when doing sudo modprobe bcm2835-v4l2: it doesn't work (error : fatal, not found).
can you please guide me to solve this issue, I have been struggling for weeks with the csi camera, given that my code was tested on ubuntu server and didn't work because of csi camera issue.

Thanks :)

excellent_self_
Автор

Can you please make a face tracking pan tilt raspi camera tutorial? Love these videos!

Fraunzi
Автор

Amazing! I think its the best video tutuorial I have ever seen!

simonvillada
Автор

Really great video! Congrats! Can you tell me what best cost-benefit relation camera to read a qr-code of 6 x 6 inches from 5 meters of distance?

asangalo
Автор

Great video! Is there a way to stop getting multiple readings of the same QR code stored in the csv? The text file currently does not store the data even though it is displayed in Thonny. Is there a way to fix this?

thejopal
Автор

Thanks for the great video. Everything worked so far. I would also like to read in a data matrix code with your program. Unfortunately it doesn't work, can you help me?

Marc-qfbs
Автор

Love the video. Can the same set up work for normal barcodes?

sidraines
Автор

i tryed this reciently w the new bookworm os but it seems the camera code is all broken/dependencys failed to install ;c, gonna try with the old OS

kingkringe
Автор

Is it possible to read the QR code that contains Pdf file url link from our database and print it immediately (just make sure the printer is connected to the raspberry pi)

terantejhastine
Автор

hello, can i do this without any problem in raspberry pi lower versions like 3-1?

franciscruz
Автор

is it possible to modify your source code so that it only recognizes qrs and barcodes in pairs (which will be very close together)?

karique
Автор

very nice video .. can i do this on a streaming live video ?

waledkhaled
Автор

I'm newbie and have problem installing library like this:
"Package libqtgui4 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsolete, or is only available from another source".
Can you help me? please

electronicsnoobject
Автор

Do you know how to read micro qrcode using python? If is possible, could you make a video to explain the steps to create a script? Thanks from Brazil!

rogeriohartungtoppa
Автор

Hello,
I am getting this error :
Overload resolution failed: > - Can't parse 'pt1'. Sequence item with index 0 has a wrong type

shreyadhume
Автор

If I didn't want a Camera, but rather to screenshare a QR code, what would I do? Get rid of the webcam but still gain the data off of, the QR code

kysevader