Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

Unusual tasks with video files – reading bar-codes and qr-codes

Unusual tasks with video files – reading bar-codes and qr-codes

IMG_1450_2rA barcode is an optical, machine-readable, representation of data; the data usually describes something about the object that carries the barcode – wikipedia. While first barcode was patented on 1952, it took quite a while until these codes were used in first grocery store on 1974. And now they are being used everywhere.

While using them looks quite obvious for countless people on a daily basis, science behind making and reading is much more complicated. I will skip this hi-tech theory and jump directly to examples how to generate and decode them using some clever Python scripts and a Kurokesu C1 USB camera connected to computer.

Generating barcodes

I will be using viivakoodi python library to generate barcodes (others like OpenCV and numpy are required, so install them before use). While there are few similar python libraries, viivakoodi supports generating CODE128 barcodes.

pip install viivakoodi

Native viivakoodi output format is SVG but I needed PNG. Quick format conversion and output file is a nice raster file.

code

Generated CODE-128 barcode

This library also can output barcode in various other formats: code128, code39, ean, ean13, ean8, gs1, gtin, isbn, isbn10, isbn13, issn, jan, pzn, upc, upca. Some barcodes can’t encode letters, some have other creation rules. Usually library this let’s know what is happening and gives you a hint. Also worth to be noted that CODE-128 has checksum fields and this library calculates it just fine.

Generating QRcodes

QRcode is more advanced barcode version. Information is encoded in 2D format.

pip install qrcode

These barcodes being two dimensional allow more information to be encoded. Also has flexibility to control how much redundant information to be used.

qr

Generated QRcode

Barcode and Qrcode recognition

Luckily there is single library to recognize barcodes and qrcodes. It’s called zbar. Let’s prepare some barbodes for automated recognition and run zbar script. While Zbar was last modified on 2011, it is still the best open-sources recognition software. It might require some tricks installing it but it is definitely worth trying. Zbar supports following barcode formats: EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code

barcodes

Sheet of paper with some barcodes and qrcodes

Results are more than satisfying. I got ~10fps recognition speed on modern computer. Video source was 1080×1080. Some barcodes were not recognized – they were to small or unsupported format.

 

out

Zbar recognition results

 

Read more Here

Pinned onto

Related Pins

ESP8266 WeatherStation Color
ESP8266 WeatherStation Color
Keyless piano project using Arduino uno
Keyless piano project using Arduino uno
IoT Wardrobe
IoT Wardrobe
Automotive CAN Transceivers
Automotive CAN Transceivers
Restoring a vintage Xerox Alto day 8: it boots!
Restoring a vintage Xerox Alto day 8: it boots!
Sonicare toothbrush teardown: microcontroller, H bridge, and inductive charging
Sonicare toothbrush teardown: microcontroller, H bridge, and inductive charging
Reverse engineering a server CPU voltage regulator module
Reverse engineering a server CPU voltage regulator module
Building a sweet plastic MIDI controller
Building a sweet plastic MIDI controller
Arduino Stopwatch
Arduino Stopwatch
App note: General overview of IR transmission in free ambient
App note: General overview of IR transmission in free ambient
Sonicare toothbrush teardown: microcontroller, H bridge, and inductive charging
Sonicare toothbrush teardown: microcontroller, H bridge, and inductive charging
App note: Using Vishay infrared receivers in a Wi-Fi environment
App note: Using Vishay infrared receivers in a Wi-Fi environment
Skill Sunday: Uploading to your Arduino via a Network
Skill Sunday: Uploading to your Arduino via a Network
One Phase Power Meter
One Phase Power Meter
WiFi Toilet Vacancy Sensor
WiFi Toilet Vacancy Sensor
HAL 9000 reimagined as a useless machine
HAL 9000 reimagined as a useless machine
Using the XMEGA Clock System
Using the XMEGA Clock System
An Arduino VU meter for classrooms
An Arduino VU meter for classrooms
DIY Calculator
DIY Calculator
Build your own robotic vacuum from scratch
Build your own robotic vacuum from scratch

Top


Shares