Last 10th of february we had another opportunity to organize a Hackday to find out how we could use a mobilephone camera as a barcode scanner.
The goal was not to have a finished implementation by the end of the day but rather to get knowledge about how to proceed and have an overview of the possibilities and available opensource products.Ā Adrian Schwaller was really interested about the outcomes of this hackday as he wanted to know how much work would be required to implement such a feature for a customer's existing application. Other goals were to make it usable from a NIWEA application using PhoneGap.Ā Which means that basically your PhoneGap application should be able to use the embedded camera's phone to take a picture, process it and extract the encoded information from the barcode then return it back to the calling application.
As we were near to clueless on the topic, we knew lot of time will be spent on investigating, gathering information. Instead of trying to do it in an organized manner by forming group focused on dedicated topic, we opted for a more bazar working style. Pierre proposed that we should spend the whole morning working independently one for each other and in any direction of our fancy. Doing so allowed everyone to investigate in what was appealing to him and then people gather themselves in a natural fashion. This allowed us to cover lot of different approaches and libraries/technologies in a very short time.
It also let us naturally form groups wich was a great experience.
Down below is a list of the things we came across:
Free barcode scanner: contrary to what the name implies, this one is not free at all. You will have to pay for it. Asking 2$ per scan seemed highly priced to us so we dropped it quickly.Ā
Quickmark: was really appealing to us after trying it for few minutes. The speed and recognition rate were really good. There again it was not free.
Redlaser: seemed also to be quite good. One has to pay for it but we couldn't find any documentation explaining how to use it.Ā
Iscandit: suffers from the same problem as earlier contender. No download to be found on the website, no documentation and no pricing nor licensing information. As Bastian found out, it's currently only available in the US. Europe is comming soon. If we would have had more time we could have contact developers and problably get more information.
Few days after announcing the hackday, we received emails from Liipers proposing ways to address the problem. Somebody suggested that we could just take a picture and send it off to a webservice for processing.Ā Although the idea seems to be good we had to discard it quickly. We knew in advance that this way won't fit our needs because following two main reasons
ā Working with a webservice gives a pretty long latency based on the network connection so we would use up more time for transferring the image or the image stream
ā The application is not usable without network connection
Brian pointed us to the Zxing library which is a Java library for barcode recognition. This seemed to be really good and on top of that as it was written in Java, an Android version of it was available from the project home page. There was also a Obj-C/C++ port available but that one only supported QR-code barcode and was not active anymore.
We (Bastian and Jean-Christophe) thought that we could actually cross-compile Zxing to Objective-C code so that it could be used on iPhone. We found that such a cross-compiler existed already, xmlvm. After installing it we managed to produce the Objective-C code without any problem. But then when we imported the code into XCode and try to compiled it we were faced with a daunting number for compilation errors. So we just dropped this idea.
Meantime Pierre, Chrigu and Thomas made some nice progress using another library for the iPhone, named ZBar. Just before going for lunch, they managed to get a basic PhoneGap application scanning barcode using this library.
The idea then was that we should use a library specific to each plateform, Zbar for iPhone and Zxing on Android and provide aĀ Javascript API abstracting away the libraries differences. The net result would be that you would write code against our API in your PhoneGap application and we would take care of calling the right function in the right library depending on the targetted device.
Hence we moved on trying to reproduce Pierre's success on Android using Zxing. Things were not that easy but after many trial and errors, we managed to get it working too. Bastian had built an Android development environment quite fast but the building of a running application used up some time. Compared to the iPhone, the Android development way has many pitfalls we had to cover.
So at the end of the day we had two small PhoneGap applications, one dedicated to iPhone and another one for Android, capable of doing barcode scanning and recognition. These were really positive results.
Of course we don't have anything close to a finished solution. There is still some work to be done in order to have a PhoneGap plugin that could be simple to use on any Android and iPhone devices. But we do know now that it is possible to do barcode scanning from within a PhoneGap application. We have selected libraries that will allow us to do it and have highlighted a way to package it as a nice PhoneGap plugin that could be used seamlessly in any PhoneGap application. With a couple of more days of work, we should be able to have this feature implemented nicely into a real application.