BlackBerry 10 WebWorks Barcode Scanner by UCOSP Students

Announcements

Perhaps the largest single contribution from UCOSP students was recently pushed to our WebWorks-Community-APIs repository: A Barcode Scanning extension for BlackBerry 10 WebWorks. Two students started working on this during the initial hackathon at Facebook. Before I talk any more about it, let’s hear from Mike, who did the first coding and bulk of the C++ investigation:

“My semester working with Blackberry under the umbrella of UCOSP has been a very rewarding and enjoyable experience. Not only have I learned a great deal and gained invaluable new skills and experience, but I have also built on my previous experiences with GitHub, C++, and mobile Blackberry WebWorks development. From the semester-opening code sprint at Facebook HQ, to finishing a native WebWorks extension, to developing and testing a Blackberry 10 mobile app, working on this project has been an enlightening and rewarding journey.

I have spent the bulk of these past four months contributing to the Barcode Reader native C++ extension for WebWorks with my colleague Alex Kwan and mentor Tim Windsor from Blackberry. The idea of creating native C++ libraries that can be invoked from a Javascript layer was intriguing to me right from the beginning, and I wasn’t disappointed in choosing this option. My contribution was mainly for the C++ portion of the extension, which involved writing code to access the BB10 native camera APIs and attempting to detect barcodes from the camera frames using the ZXing image processing library. Development of the extension initially proceeded quite smoothly. The native APIs for accessing the camera and processing frames from the viewfinder were simple enough and sufficiently documented, and the Zxing library was fairly straightforward to use. Within a month the basic functionality of the Barcode reader was implemented, and our extension was capable of scanning barcodes.

The majority of the challenges involved with this project resulted from attempting to pass the image frames captured by the camera viewfinder back to the WebWorks layer. My colleagues and I experimented with several options; although many initial solutions we tried ended up being infeasible due to various performance-related issues, we finally managed to come up with a solution that works well and the extension is now ready for release.

In addition to working on this exciting new extension, I’ve also had the good fortune of building on my
previous experience with mobile development and creating a new WebWorks app for Blackberry 10. For the remaining week of this term, I’m looking forward to completing and refining my application. The WebWorks SDK is straightforward to use and it’s easy for novice mobile developers to get started with it, and Tim’s Ant build script greatly simplifies the process of building and deploying apps to your BB10 mobile device.

Overall, working with both native extensions and the WebWorks SDK was a great learning
experience, and I would highly recommend developers to contribute extensions for providing any functionality they feel is currently lacking in the Blackberry WebWorks SDK.”

Once Mike had the initial C++ code working, another student worked on wiring in Javascript connections so that it could be called from an extension (I’ve saved that students thoughts for the next blog post in the series). Finally, I took the code at the end to finish integrating it together with some tweaks and testing on different devices. As Mike stated, the hardest challenge was with showing the user what they were aiming at. As the JNEXT interface between C++ and Javascript can only handle string data, we were unable to have the viewfinder paint video or even images directly. The solution in the end was to capture burst images from the camera, save them to the filesystem, and pass the file path to the Javascript layer. The resulting image stream isn’t as smooth as direct painting, but the actual scanning and interpretation of barcodes is unaffected, so users have the ability to aim, and the scanning is as fast as any pure native solution.

This is an outstanding example of what these Canadian university students are capable of, and it’s awesome to be able to work with them. If you’ve been looking for a Barcode Scanner API for your BlackBerry 10 WebWorks app, check it out on Github.

About Tim W.

Tim works on the Developer Relations team at BlackBerry, focusing on WebWorks, HTML5, and Open Source.

Join the conversation

Show comments Hide comments
+ -
blog comments powered by Disqus