TWiki
> Experimental
> Sensors >
Barcodes2d
Barcodes2d - Using 2d Barcodes to Trigger Mediascape Actions
2d barcodes are similar to the kind of barcodes that you may find on a tin of beans in a supermarket, except that they contain data arranged over two dimensions rather that just the one. This means that a lot more data can be stored in 2d barcode than a traditional 1d version, for instance an entire URL can be embedded easily. The Barcodes2d object allows mediascapes to include this exciting new technology as part of the experience.
Most Windows Mobile 5 or above devices that contain a built-in camera should be compatible with this object.
|
|
| Example of a 2d Barcode |
Reading a 2D Barcode using an HP iPAQ 6815 |
Characteristics
Interaction Model
In order to read a 2d barcode as part of a mediascape, the user will need to activate the code reader. This may be done by pressing a button, tapping the screen, or via another interaction that the designer of the mediascape has deemed appropriate. The screen of the device will then switch over to a video feed from the camera. The user must aim the camera at the barcode so that it fills enough of the screen for the system to be able to read the code. Once the code has been successfully read, the mediascape action associated with that code it activated, such as playing some audio or showing an image etc. The system also has the notion of
pop-up text - this is a string of text that will appear on the code reading screen during the time that the camera is over a code. This is often used as a way of telling the user what will happen if they were to activate the code.
Range
The exact range depends on the physical size of the code, the amount of data that is and the optics of the camera. For a code of around 3 inches square, containing the text 'this is a test' a iPAQ 6815 will need to be around 15-20 cm away.
Latency
The complete process from deciding to read a code to the associated action occurring is a few seconds for a practised user, and rather longer for a first time user. In general it it probably best to avoid designing a system where many codes must be read in quick succession.
Hardware
Provided that your mediascape device has a built in camera and runs Windows Mobile 5 or above, no extra hardware is required.
Click the link below to view the compatibility chart that lists which mobile devices are compatible with the 2dBarcodes system.
Mobile Device Compatibility Chart
The 2d Barcodes themselves can be generated and downloaded in a couple of different ways, see
Generating 2d Barcodes below for details.
Using 2dBarcodes in mscape maker
To add to 2d Barcode capability to your mediascape, you should add the Barcodes2d object.
- Start mscape maker
- Right-click on 'Sensors' in the list of mediascape objects.
- Select 'Add Barcodes 2d'
The Barcodes2d object has two events,
OnCodeRead and
OnCodeLost which are triggered when a barcode is read, and a few seconds after a barcode cannot be read any more respectively. The Timeout property on the Barcodes2d object is used to set the exact length of time after a code cannot be seen until the
OnCodeLost event is triggered.
These events are useful when you do not know at the time you are building the mediascape which barcodes will be encountered during the running of your mediascape. Both of these events have a parameters 'URI' and 'PopupText' which contains the URI and pop-up text embedded in the 2d barcode respectively.
Generating 2d Barcodes
2d Barcodes can be read either from the printed page, or even directly off a computer screen. To generate your own custom 2d barcodes, you can use one of the services that we provide.
Using mscape maker (recommended)
mscape maker has the capability to generate codes once the 2dBarcodes object has been added.
- Right-click on Barcodes2d on the left-hand panel
- Select Generate Barcode
|
| The Generate Barcode screen in mscape maker |
Note that this function connects to our barcode generation system on the internet, so net access is required. If you access the internet through a proxy, ensure that it is set up correctly in Internet Explorer.
- Enter the URI text you require. Note that you can actually use free-form text in any format, you are not limited to URI formats such as http://www.hp.com.
- Enter the Popup text you require (if any). This text will appear over the video feed from the camera when the 2d barcode is read. If you intend to immediately display content such as video, images, or web pages when this code is read, the popup text will not be visible. In this case you should leave the Popup text field blank.
- The size field controls the size of the output image. The default of 7 will produce an image about 160x160 pixels, though the exact size depends on the amount of text in the URI and popup text fields.
In general, it is best to have the minimum possible amount of data in the barcode, as more text will result in a denser barcode which is in turn more difficult for the barcode reader software to process.
Using the ActivePrint Website
It is possible to generate codes using the
ActivePrint Code Generation Page.
- Go to http://www.activeprint.org/codes.php
- Enter your popup text into the appropriate field (if popup text is required)
- Choose 'Web' as the link type. Do not use SMS Dial Contact or Data, as these all insert extra hidden data into the code which will not be correctly processed by mscape.
- Enter your URI. If you are using plain text as opposed to an actual URI, a message will pop about the data type being invalid. You can safely ignore this.
- Choose Datamatrix as the Code type. This is very important, as QR codes cannot be read by the Barcodes2d object in mscape.
- The size field controls the size of the output image. The default of 7 will produce an image about 160x160 pixels, though the exact size depends on the amount of text in the URI and popup text fields.
- Hit Submit to generate the code.
- You can save the code to your computer by right-clicking the image and selecting 'Save Target as' or 'Save Image as'.
Example
This example will show the webpage embedded in a barcode if the URI starts with
http:// and will play an audio if the URI is "playASound".
Place the following code into the
Buttons object's
OnCenter event.
Barcodes2D.Start();
This enables the user to start the barcode reading process by pressing the central cursor button on their device.
This code should go in the Barcodes2d'
OnCodeRead event, and requires that the WebPages object (right-click on Media and select Add Web Pages) and an audio called myAudio are in the mediascape.
Barcodes2D.Stop();
if (URI.StartsWith("http://"))
{
WebPages.LoadUrl(URI);
}
else if (URI == "playASound")
{
myAudio.Play();
}
|
Once a code has been read the barcode reading process is stopped. The user will need to press the central cursor button again to restart it.
Using Barcode2d Object in mscape maker
If you do know in advance the contents of the barcodes that will be used in your mediascape you may find it useful to use the Barcode2d object. This object is a child of Barcodes2d, and essentially allows you to associate an
OnEncountered and
OnLost event with a known Bluetooth name.
- To add a Barcode2d, ensure your mediascape contains a Barcodes2d object. If not, follow the instructions under Barcodes2d Object to add it.
- Right-click Barcodes2d and choose 'Add Barcode 2D Device'
- In order to match the new Barcodes2d object with a real 2d barcode in the field, you must type the Uri embedded in the barcode into the Uri property of the Barcodes2d object using the properties box. Note that the URI is case-sensitive.
Unlike most other sensors, the Barcodes2d object
must be explicitly set to read mode before any barcodes can be read.
To do this, use the
Barcodes2D.Start(); function. This function is commonly assocated with a button on the device, which is achived using one of the events on the mediascape's
Buttons object such as
OnCenter.
By default, the code reader will stay active once a code has been read. If this is not the behaviour you require, you could use the
Barcodes2D.Stop(); function in the
Barcodes2D.OnCodeRead event. This will stop the code reader as soon as any code has been read.
Setting up mscape player to use Barcodes2d
Barcodes2d should not require any setup on mscape player. If your device has a compatible camera, and the
Barcodes2D.Start(); call has been made in your script then the video feed should appear. If your device does not have a compatible camera, then you may get an error message.
No COM PORT setup is required for Barcodes2d.
Fix for rotated or inverted video feeds
Some devices will display the video feed reversed or rotated. If this happens to you then you can either wait for version 2.2 experimental release, or if you want it fixed right now you can apply the patch below.
- Download the file by right-clicking and selecting 'Save File As' or 'Save Target As'
- Connect your mobile device to your PC and copy the file to \Program Files\mscape\extensions
- Start mscape player, load a mediascape that uses barcodes2d.
- There'll be a 'rotate' button at the bottom right of the screen, click this to get into the settings screen. You can set the rotation of the video feed as well as the vertical flip - these settings will persist between sessions.
HP.Easel.Experimental-CF.dll