For work I need to implement a strange usercase: I need to have a form with QRCode and BarCode input.
The short story: I need to read the info from a BarCode and find the book.
The long story: I need to read the barcode with a phone/tablet/something with a camera and post it in a django form. So I search on the web and find some solution.
The premium solution
First solution I found is a premium solution. I find the Dynamsoft ’s tutorial where you can build a script for read QrCode, BarCode, etc… but you need a license for your code to work. It’s an easy way IF you have the budget and I don’t have it. So I need something different. An AI?
The AI solution
After more searching I find some Google and Amazon solution for reading BarCode with AI but
- It isn’t free, it is a premium services
- It’s hard for the server (CPU intensive) and you need to send the photo to the server
- You can run the code on the client but you need to make an app (iOS or Android)
So I need another solution.
I find a Perl solution (a big no no for me), some more Python solution (but you need to know where the BarCode is) and some magic tricks find in StackOverflow.
And searching in StackOverflow I found the solution: an JS solution.
So I search some JS library and find a library: Html5-QRcode
The final solution
Making this template for the form you can scan the BarCode from the cam of the pc/phone/table and push the form with the info read.
This code fragment is indipendent from the django version and the software installed in the server. It’s also all client side code so the server get only the string inside the BarCode/QrCode.
If you liked this article,
please share it on