QR Code Reader and Catalog RaspberryPi Part 1

ᎣᏏᏲ. ᏙᎯᏧ? Hey, welcome back!

I have a storage room, garage, and a workspace. I’m planning to use this to catalog everything from collectibles, Christmas decorations, electronics, leather works, models, research materials, and more. I want to be able to search for items I need and find where they are located in my massive collections.

A while back I wanted to use a QR code app entitled QuickPeek to catalog the hundreds of collectibles I have so I could know what was in each box. The app is great. You scan in a QR Code and make a new box. You then take photos of items and add them to the boxes. Then you can look up items and find out which box they’re in or even look at pictures to see what items are in a box. The problem is that the app didn’t work on my phone. I still have it installed. I wasn’t going to spend the money to buy their QR codes. I bought a roll of 100 QR codes for like 4 bucks or something on Amazon. For whatever reason these QR codes didn’t work with their app. So I need something I can use. Enter my RaspberryPi.

With all of the work I’ve been doing on SERINDA V2 some of it has been with barcode detection and cataloging. Some of this has been for purposes like a nutrition app that you scan a barcode and it looks up the product then tells you what the nutritional values are. Some of this has been for AR/MX so you can scan a barcode and see a 3d model in Augmented Reality or Mixed Reality. And even still some has been so you can scan a barcode of any item and it will do a lookup to find that item for sale somewhere on the net. These uses are in various phases of development. However, the barcode implementation (barcodes and QR codes) is complete. Now, I need to wire the output for a function. I.e. once I have the output I can do the nutritional lookup, item lookup, AR lookup, etc.

I thought I would decouple the process from SERINDA. It’s a standalone class in SERINDA, but I wanted to go one step further. I’m including links to the two PyImageSearch articles that I used, originally, for SERINDAs application. If you are interested in OpenCV and haven’t gone to http://pyimagesearch.com you’re missing out. I’ve been following and reading his work for about 5 years. I’ve been a Plus subscriber to his content for like a year. Well worth the 5 bucks a month. I’ve learned tons from Adrian. As well, if you’re wanting more content in OpenCV you should checkout Satya’s work over at https://www.learnopencv.com/

Here are the basic functions we need:

  • Take a pic of a QR code/Barcode
  • Create a new virtual box for stuff to go in
  • Take pictures of items to add to the virtual box
  • label pictures with a title and/or tags (e.g. Star Wars, Battlestar Galactica, Dishes)
  • lookup items via QR code/Barcode
  • type in a tag to look up items
  • type in a title to look up items
  • open a box and view contents – shows what QR code/barcode they’re related to in plain text
  • location of box – this could be as simple as “garage” or “attic” – it could be as complex as “storage shelving 1, garage, top shelf” – I need to think more about this but I’d like to be able to tell where things are.
  • backup database to cloud (google drive, dropbox, other)

I may have more elements to add to this, however, for now I think this is enough.

This tutorial section is going to be accomplished through multiple parts:

  1. Combine Barcode with Streaming video – detect a barcode and print out what the QR code or barcode is
  2. Flask server set up, show the streaming video, print out the barcode/QR code found on the page
  3. set up SQLite, create the database and tables, CRUD using barcode/QR code
  4. using Flask – create a new box, assign a QR code to that box
  5. take snapshots using Flask and camera/picam then assign those to a specific “box” that we have created
  6. add tags and titles to images that we’re storing as well as what location that box is in (basically additional tags for locations ie. garage, shelving unit 1, top shelf, etc or even “in the attic on the left side
  7. open a “box” and view the pictoral contents
  8. search all of the boxes for tags and titles displaying those results on the page
  9. remove an item from a box
  10. update labels, tags, titles, locations of an image in a “box”
  11. upload backed up database to google drive or dropbox
  12. replace current database with one backed up on google drive or dropbox

I think those are all of the steps. I am probably missing something, but we’re going to start with these. When this is all over I’ll include the steps for a FastAPI server that can be used in place of Flask.

Why did I choose Python (and Flask) instead of say React Native or something else? I wanted this to be quick, easy to use, and portable. I didn’t want to spend time with putting an app together for a phone and then what flavor of phone. I can use this app on any of my computers including my raspberry pi. The idea is that I can pick up the raspberry pi and take the screenshots, but I could just as easily use my computers webcam or an external webcam the same way. In addition, I have far more experience with Python and OpenCV than I do with React Native, Flutter, Angular, Vue or another web framework. I can do all of this work with HTML, CSS, and Javascript and rapid prototyping.

All of the code will be available in folders in Github.

I will do my best to componentize the code so it can be reused in other projects if you want. I hate large sets of code woven into one giant codebase. Create multiple files, there’s no reason for one giant section of code.

To start I’m going to use portions of the following two PyImageSearch articles. As I said before, Adrian has superb tutorials and I’ve learned a lot from his work. This first section is going to combine the barcode reader with streaming code.

I’m working on the individual tutorial elements now. When they’re complete I’ll publish them and do a live stream for each one.

Until next time. Dodadagohvi. ᏙᏓᏓᎪᎲᎢ.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.