Home   Archive   Permalink



QR and bar code scanner from mobile device

Although I'm thinking in trying to do it for Red, as I've read what Nick has developed for Merchants' Village, I ask it in this Rebol's forum.
    
What are the possibilities of having Android and iOS smartphones reading bar and QR codes?
    
As I've read, Nick has done a similar work, but using bar code scanners.
    
The first step would be to open the camera in a way similar to https://groups.google.com/forum/#!searchin/red-lang/camera/red-lang/EEs3KhNmwWc/PYC8rxQYcwcJ
    
Then it's necessary to implement an algorithm to read the bars or QR codes. What directions could you point me?


posted by:   Libertas       13-Jul-2015/5:04:04-7:00



The Merchants' Village software uses handheld retail bar code scanner devices which plug into USB ports on desktop machines, so the routine is totally different than what you're intending to do on a mobile device. In the Merchants' Village setup, the hardware devices do the scanning, and also the decoding. The scanners are set up so that they appear to the PC as keyboard devices. So, the decoded bar code data appears to the application exactly as if it has been typed in by a user at a keyboard. (the printing routine is much more complex - an algorithm (contained in a library written in pure Rebol) is used to generate images directly from the bar code data, and those images are laid out on a page using some additional pure Rebol code (and a library written in pure Rebol which outputs PDF documents)).
    
If you want to decipher bar codes and QR codes from images, you'll either need to access an API created to help with that purpose (google "bardcode api android", for example), or create such a library in pure Red. It's certainly possible to create such a library which performs the algorithmic process in pure Red, but no one has done that as far as I know (or in Rebol). That involves some heavier lifting (image recognition, etc.), most of which has been encapsulated by those multiple libraries which perform bar code recognition and provide APIs to retrieve the data.
    
Whatever your goal, you should probably start by looking at existing bar code libraries on the platform(s) you want to target. There is some documentation about using external libraries in Red: http://static.red-lang.org/red-system-specs.html#section-15 . There is a long list of library bindings already done in Red: http://www.red-lang.org/p/contributions.html . That should provide plenty of examples about how the external library interface works. If I remember correctly, there has also been some successful work done on a Java bridge interface (there was a Java (maybe Android) GUI example screen shot published more than a year ago...).
    
If your goal is to develop a library in pure Red, I'd think the best way to begin would also be to look at an existing library. Start with examining how they've accomplished each of the necessary processes - then all you have to do is translate the alorithms, data structures, I/O, etc. from whatever language is used, into Red - that should be easier than starting from scratch ;)

posted by:   Nick       13-Jul-2015/8:34:30-7:00