Real Time Scanning and Storing QR Codes With Raspberry Pi and OpenCV

Hi Chase,

When asking for help, it’s critical you attach a screenshot or copy-paste of the exact error message you got, otherwise we won’t know where to look! :slight_smile:

This one is a bit easier to troubleshoot thankfully, Tim has a great guide here:

You’ll just have to select the “Legacy” OS when imaging:

1 Like

Not sure how to screenshot on Raspberry Pi yet.

Also, thank you very much for the prompt response. I am loading Legacy onto another card and will try entering the code into that one. I do not yet have a QR code scanner or camera however. Perhaps this has to be connected for code to work?

1 Like

Hi Chase,

You will need a camera eventually, but installing shouldn’t need it (to my knowledge)

Let us know how legacy OS goes!


After getting a 16 MP Ardu Cam and running the code on (Legacy) with camera enabled this is the error code i receive. What does it mean?

1 Like

Hey mate,

Lets take a step back and see if you are able to take a photo with the current hardware. Follow this guide to check - Raspberry Pi High Quality Camera – First Pictures and Videos - Tutorial Australia.

If that doesn’t work it is likely there is a need to use a different driver for the Camera module so that it can work with Buster OS. You will find exactly how to do that with this forum post here - 16MP Autofocus & Raspbian Buster --> **no camera available** - libcamera - Arducam Camera Support Forum

Once that is sorted you will be able to get right into scanning QR Codes :blush:.

Kind regards,

Thanks for the idea about this, tried and it works but too much delay so im thinking on configure the resolution for smoother and light task for my Raspi 3 B do you have insight for this matter?

1 Like

Hi Mgate,

In my experience, the two things that can improve performance in CV applications is to lower the resolution being fed into algorithms, ideally lowering what comes out of the camera itself to avoid an intermediary step, and turning off preview. If you can run your application “headless” where it isn’t having to render a preview, it can speed things up significantly.

Have you tried either of the above?


Hello Tim,
thank you for making this guide, it helped me a lot. I was using this code to scan QR codes for a project last year and everything was working fine. Then I didn’t use the Pi for several months and now that I got back to it the same code is not working anymore. I think the problem might be related with the new updates that happened in the meantime (buster to bullseye) but I can’t be sure about this. However, even if I remain on a Buster system, the code won’t work: it is like the camera is not detected anymore and the result of the line “” is always [False, None]. It has been now various days that I try to solve this problem without any results. I also tried to re-install the Buster operating system from scratch from the link provided in the beginning of this article but nothing changed.
Can you help me somehow? What is the correct way to access a camera nowadays?
Thank you in advance

HI , I have tried the code with a 5mp camera and a Raaspberry PI 3B , but I keep getting this error, can you help me solve this please

Hi All,

The tutorial video by Tim is great, however, has anyone managed to get real-time qr code scanning on Bullseye yet?

I am getting the following error: failed to allocate memory, failed to create pipeline due to which img is null
also im unable to install pip3 install opencv-contrib-python==
and sudo apt-get install libqt4-test python3-sip python3-pyqt5 libqtgui4 libjasper-dev libatlas-base-dev -y
Can anyone please help?