Tag Archives: development

Keyboard for barcodes

The prototype application will be for devices that run iOS 5. We are developing a proof of concept and can look at developing for a wider range of devices in the future.

The best case scenario means that users can scan barcodes with the camera on their iOS device. In reality, this will only be possible with the iPhone (3GS, 4 and 4S). The iPod Touch and iPad 2 have a fixed focus camera that isn’t suitable for scanning nearby objects. In fact, the Open Source ZBar bar code library we are using says that these devices aren’t supported. The original iPad and older iPod touches have no camera. Even for those devices with suitable cameras, the barcode may be faint or damaged .

We therefore need to allow for the manual entry of barcodes via a keyboard. In iOS you have a number of prebuilt keypad layouts, including default (standard keyboard), email (standard keyboard with an at sign and period) and numeric. The closest suitable pre-built keyboard was numeric (0 – 9, Delete). However, I also need to accommodate the characters ‘x’ and ‘-‘. We don’t actually need the dash (‘-‘) for searching ISBN numbers, but I thought it would be less confusing to allow the user to enter the character if it was on the back of a book.

I therefore created a custom keyboard. The image below was my first attempt:

First attempt at a barcode keyboard

However, it was pointed out that most numeric keyboards only have 3 buttons across. So, this led to my second attempt:

Second attempt at a barcode keyboard

This is more familiar and has larger buttons – especially useful for people with clumsy fingers like myself.

Any thoughts and suggestions welcome :).

Update

Based on some feedback I’ve increased the size of the X. I’ve also nudged up the size of the dash.

Third attempt at a barcode keyboard

The different shade of grey is an artefact of the way I took the screenshot, I think.

Scanning Barcodes – supporting Telepen

One of the key pieces of information for discovering bibliographic data will be the barcodes on the books – either the barcode used by the Library at the University of Bristol or the ISBN numbers associated with the books.

It would be nice if we could take advantage of the camera on the device to scan the barcode and save the user from having to type the numbers in manually. There are a couple of libraries for scanning barcodes:

  • ZXing (Zebra Crossing) – a Java library with Android support. There is also a partial port to iOS that only supports QR Codes.
  • ZBar – a C library that has bindings for a number of languages and includes an SDK for the iPhone.

These libraries have good support for a number of formats such as UPC-A, EAN-8, Code 128 and QR Codes. However, they don’t support the proprietary telepen format that is very popular in UK academic and public libraries.

It therefore seems that one of the first key development tasks will be adapting one of the libraries to support for telepen barcodes.

Validating barcode numbers

It would be great if the app could send a barcode number to the web service without the user being forced to decide upfront what kind of barcode is being sent, e.g. a barcode used by the library or an ISBN number. Clearly, the service needs to know what kind of number it is dealing with to make a sensible decision on what bibliographic source to query.

I’m exploring the use of validators to help the service to determine what type of value we are dealing with. At the moment, the interface is pretty simple:

public interface Validator {
    boolean validate(final String value);
}

Basically, an implementation would take a value and determine whether or not it believes it is valid. The first implementation developed covers the barcode numbers used by the Library at the University of Bristol.

Barcodes at the University are ten digits long and follow the following format:

  • The first digit is the prefix and is always the number 1
  • The second through to the 9th digit will be from the range 0 to 9.
  • The tenth digit is the check digit and can range from 0 to 9 or be the character X

The validator can therefore declare any value it receives that is not 10 digits in length as invalid. It can also dismiss any 10 digit numbers that don’t start with 1. Beyond that we need to apply an algorithm that determines the validity of the check digit (tenth digit) against the other numbers (excluding the prefix).

Each number is multiplied against a relevant weighting in the following list: {7, 8, 4, 6, 3, 5, 2, 1}. Modulus 11 is then used on the sum of the weighted values to get a remainder. The remainder is then subtracted against 11 to get the check digit value. If the value is 10, then that is represented by the character X. Clear as mud?

So, for the barcode 1511075964, we ignore the prefix and multiply the next 8 digits against the appropriate number in the weightings list:

(5 x 7) + (1 x 8) + (1 x 4) + (0 x 6) + (7 x 3) + (5 x 5) + (9 x 2) + (6 x 1) = 117

Find the remainder:

117 % 11 = 7

Subtract from 11 to find the check digit:

11 – 7 = 4

Therefore, 1511075964 is a valid University barcode because the last number matches the check digit created by the algorithm.

ISBN 10 numbers have ten digits but use a different weighting to calculate the check digit. It will be interesting to calculate the probability of a clash – the possibility of a number being a valid University barcode number and a valid ISBN 10 number.

Technical Architecture

For the mobile application to obtain citation information, it needs to be able to associate a physical item (such as a book) to the relevant bibliographic information. We plan to provide a RESTful service that can take a lookup value, such as a barcode number, and then search bibliographic sources for useful data for the user. For example, in the case of our library stock, each item has a barcode number that can be used as a unique identifier to search our library catalogue, Aleph.

It is better to provide a intermediate service rather than allowing the application to query Aleph directly. It will be easier to extend the service to support different and multiple bibliographic sources without having to update the application on the phone. The service will just continue to return data in a format that the application understands.

The service can also be used to store and query the usage statistics that are of interest to the library staff.

Below is a diagram of the planned architecture:

Proposed architecture

I’ve already made a modest start on the development of the service, by querying Aleph through the X-Service API for details of a item via a barcode lookup. For those interested, I’m using JAX-RS (Jersey) to provide the RESTful service and the Spring Application Framework for dependency injection.