Skip to content

Scans barcodes and QR codes in real-time from your phone's camera or computer's webcam

Notifications You must be signed in to change notification settings

iArpanK/Realtime_Barcode_Reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Realtime Barcode Reader


Scans one-dimensional barcodes and QR codes in real-time from your phone's camera or computer's webcam. Can be run directly from your command-line or terminal. This application is built using Python 3.7 and uses the following libraries:

  • OpenCV
  • Pyzbar

Dependencies


Install OpenCV

$-> pip install opencv-python

Install Pyzbar

$-> pip install pyzbar

Running the Program


After all the required libraries have been installed, the program can be run as

$-> python realtime_barcode_reader.py --video <source>

In place of source, enter the URL of your IP Camera application. Format for this is http://<IP_address>:<PORT>/video.

For example, I'm using an Android application called DroidCam which shows these two instances.

1616989007121 1617037915127

  1. First instance : I connected my computer to my phone's personal hotspot
  2. Second instance : I connected my computer & phone to a WiFi

So in the first instance, my source URL would be http://192.168.43.1:4747/video. And the complete command would be

$-> python realtime_barcode_reader.py --video http://192.168.43.1:4747/video

And in the second instance, my source URL would be http://192.168.43.39:4747/video. And the complete command would be

$-> python realtime_barcode_reader.py --video http://192.168.43.39:4747/video

NOTE : In both these instances, note that your computer needs to be connected to the same network as your phone. Also, keep the IP Camera application running in your phone.

If you want to use your computer’s primary or secondary webcam as the video source, use source as 0 or 1 respectively, in the command above. For example, the below command starts your computer’s primary webcam as the video source.

$-> python realtime_barcode_reader.py --video 0

On punching either of these commands as per your choice, the realtime_barcode_reader.py program will start executing displaying a startup message on the command line, and your phone/computer will start streaming video feed. At the same time, a new window will open up on your computer screen displaying the barcode reader’s output stream (as shown below).

Now we are ready to scan different barcodes!

Screenshot (171)

To exit the program, press the ESC key on your computer.

Sample Runs


Attached below are some sample shots of the barcode reader.

Untitled collage

Log


On every run, this program generates a log file (log.txt) which contains the exact last session timestamp and details of the unique barcodes scanned.

Screenshot (169)

Notes


For IP Camera application, you can download either of these apps:

DroidCam

IP Webcam

Google Drive download link (ipynb file included) ⤓

Thanks!

About

Scans barcodes and QR codes in real-time from your phone's camera or computer's webcam

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages