Skip to content

Scanning barcodes with linux and a webcam

My Nokia phones can do it, so I thought there must be a way to do it on my laptop too. I wanted a way to scan both "traditional" barcodes and "two-dimensional" ones, like the QR-Codes. Here is my solution.

You'll need :

- a v4l-compatible webcam + mplayer compiled with v4l support (or any other scriptable way to grab frames from the webcam)

- a scriptable image viewer, I use feh on my laptop

- ZXing

Follow the instructions to build the ZXing javase component, then open three shell windows, and run:

shell1 (grab the webcam output as last.jpg +- every half second):
cd /tmp ; while [ 0 ] ; do mplayer tv:// -fps 2 -tv driver=v4l:width=640:height=480:device=/dev/video0 -vo jpeg:quality=95 -frames 2 ; mv 00000001.jpg last.jpg ; done

shell2 (view what you grabbed):
cd /tmp ; feh -R 1/2 last.jpg

shell3 (scan for barcodes):
while [ 0 ] ; do ( java -cp javase/javase.jar:core/core.jar com.google.zxing.client.j2se.CommandLineRunner /tmp/last.jpg | fgrep -v 'No barcode found') ; sleep 1 ; done


So no nice GUI, but it seems to work well.


  • Twitter
  • Bookmark Scanning barcodes with linux and a webcam at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Scanning barcodes with linux and a webcam
  • Mixx Scanning barcodes with linux and a webcam
  • Bloglines Scanning barcodes with linux and a webcam
  • Technorati Scanning barcodes with linux and a webcam
  • Fark this: Scanning barcodes with linux and a webcam
  • Bookmark Scanning barcodes with linux and a webcam at YahooMyWeb
  • Bookmark Scanning barcodes with linux and a webcam at Furl.net
  • Bookmark Scanning barcodes with linux and a webcam at reddit.com
  • Bookmark Scanning barcodes with linux and a webcam at blinklist.com
  • Bookmark Scanning barcodes with linux and a webcam at Spurl.net
  • Bookmark Scanning barcodes with linux and a webcam at NewsVine
  • Bookmark Scanning barcodes with linux and a webcam at Simpy.com
  • Bookmark Scanning barcodes with linux and a webcam at blogmarks
  • Bookmark Scanning barcodes with linux and a webcam with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Print this article!
  • E-mail this story to a friend!
  • Identi.ca