Giter Site home page Giter Site logo

qr-code-reader's Introduction

QR code reader on a Raspberry Pi 3

This guide will show you how to create a QR code reader by using the zbarlight python library and fswebcam to take the picture. We will not be using open cv or any other image processing libraries.

What you'll need

  • Raspberry Pi 2 / 3
  • MicroSD Card with Raspbian on it (Tutorial)
  • A USB webcam
  • Micro USB cable
  • Keyboard, Mouse, Monitor
  • HDMI cable for the monitor

If you are using the Raspberry Pi headless (Without a monitor, keyboard or mouse), You will need to connect to the internet using the ethernet port (for Raspberry Pi 2) or through the Wifi (on a Raspberry Pi 3 [Tutorial] ) and then you will have to use SSH to connect to your Raspberry Pi.

Installation process

Here onwards everything will be on the terminals. Press CTRL + ALT + T to open up the terminals.

STEP 1 - Initial installations

The apt-get must always be kept updated.

sudo apt-get update -y && sudo apt-get upgrade -y

This will take some time depending on your internet speed and also the amount of package's that are installed onto your Raspberry Pi's OS.

STEP 2 - Installing and running fswebcam

You will need to install this to access the webcam from the commandline. To install this you will need to use apt-get.

sudo apt-get install fswebcam

This will install fswebcam. Now insert your USB webcam, to check if it's connected, enter in the command

ls /dev/ | grep video

If video0 is the output that means you are good to go, The webcam is connected. Now enter:

sudo fswebcam image.jpg

This will take a picture named image.jpg. To check if you have taken the image, Enter:

ls | grep image

If you see a file named image.jpg, that means your web cam is working. But if your above output for ls /dev/ | grep video was something else, for example video2. We have to pass an additional argument to sudo fswebcam image.jpg. Which is:

sudo fswebcam -d /dev/video2 image.jpg

There is one more argument that we pass through to this command which is -q which means quite, This is to avoid the extra wordings that come when the photo is being taken.

STEP 3 - Installing zbarlight

This is the brain of our QR code reader. This library helps us to decode an image into their basic codes.

First we have to install the following:

sudo apt-get install libzbar0 libzbar-dev

Then we have to install the zbarlight

sudo pip install zbarlight

After this you can run the reader.py python program that I have written to test if it works. But before you proceed, we need to create a folder named qr_codes right outside the reader.py file. This folder will store all the QR codes.

This reader.py program does the following:

  • Runs the command fswebcam -q image_name.ext
  • Checks if it has QR Codes
  • Stores the QR code onto the qr_codes/ folder
  • If there is no QR code present after we run it through zbarlight, the image is deleted.
  • Else the image stays there, and a qr_code_messages.txt file is created with the QR code message onto it.
  • This file seperates the messages with certain delimiters

If you want to run the code enter

sudo python reader.py 0

This is all you need to do / know for the QR code reader to work, If you want the detailed explationation of the code, I will be writing it soon.

qr-code-reader's People

Contributors

parsa-rajabi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.