Project Tokyo QRCode Scanner

Time to talk a little bit about the QrCode Scanner implementation for the q·:card and q·:launcher application. The goal was to achieve a continuous scanning process for reading in a QR-code into our applications. Our first approach was to capture screenshots of the entire screen every n milliseconds and to handle the encoding in multiple threads. Since almost every modern android smartphone has an autofocus camera feature, we follow this approach in our scanner. The benefit is the enhanced decoding time: if we feed the decoder with sharp images, it will take less time to extract the QR-code information.

So let us take a look at how this is done: Here you can see a diagram which shows the message passing flow between some components of the QR-code-scanner. AF stands for “autofocus” and PF stands for “preview frame”. Requesting a preview frame means that we simply want to take a screenshot of the entire screen now. So after starting the scanning process, we are calling for an autofocus. When this is done, our AF callback comes into play which passes along a message with the intention to get a preview frame of the (sharp) image. Then the next autofocus request is fired. The Previewframe Callback sends a message to the so-called DecodeHandler which runs in a seperate thread, the DecodeThread, which is implemented as a “piped thread”. That means that the thread offers a “Looper” which runs a message loop for the thread.

In this way, we get a continuous scan until a QR-code is found. When a QR-code has been found by the decoder, all messages will be cleared from the queue, which leads us to the end of the scanning progress.

Actually, this approach works very fine and quick. Nevertheless, optimizations are possible in several areas. For example, we could also request screenshots when there is no sharp image representation in in the hope of getting a sufficient image quality of the QR-code to decode it.

Bernd, Project Tokyo Team

, , ,
  • Delicious
  • Facebook
  • Digg
  • Reddit
  • StumbleUpon
  • Twitter

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>