This section explains how to get and run the DrawingInTheAir example to try the pattern matching engine ability to learn and recognize letters. The following section illustrates how some functions of the pattern matching engine library (CuriePME) and CurieIMU are used in the DrawingInTheAir code for the successive parts of the code that involve learning, collecting data, reading data, filtering data and learning letters. 

Running the DrawingInTheAir Example 

The DrawingInTheAir example guides the users to draw letters in the air using their Arduino 101* (branded Genuino 101* in some countries) board as an imaginary pen, and have the letters being recognized as patterns stored in the accelerometer data from the CurieIMU library. The DrawingInTheAir example is available in the examples folder of the Intel-Pattern-Matching-Technology library.

Requirements

You need to connect a push button to digital pin 4 on the Arduino 101* (branded Genuino 101* in some countries) board.  We suggest the following:

To use the DrawingInTheAir example, first clone the Pattern-Matching-Engine-Technology GitHub*

$ git clone https://github.com/01org/Intel-Pattern-Matching-Technology

Store the content of the repository under CODK-A/arc/libraries or under CODK-M/arc/libraries.

Open the Makefile of the DrawingInTheAir example and check that the paths to the three library files Arduino.h, CurieIMU.h and CuriePME.h  are correct

LIBDIRs = $(ARDUINOSW_DIR)/libraries/Intel-Pattern-Matching-Technology/src \
                   $(ARDUINOSW_DIR)/corelibs/libraries/CurieIMU/src \
                   $(ARDUINOSW_DIR)/corelibs/cores/arduino \

From within the CODK-A directory, or the CODK-M directory, check your serial device name:

$ dmesg | grep tty

Open Cutecom in a different window, update the serial port name in Cutecom if needed, as illustrated in Connecting and Verifying the Board Proof of Life

$ cutecom &

In the terminal window, run the following command to convert the DrawingInTheAir.ino sketch to a C++ file and build the application:

$ export CODK_DIR=$(pwd)
$ cd $CODK_DIR/arc/libraries/Intel-Pattern-Matching-Technology/examples/DrawingInTheAir
$ make convert-sketch SKETCH=DrawingInTheAir.ino
$ make compile
$ make upload SERIAL_PORT=/dev/ttyACM0

Go to the Cutecom window, wait for a few seconds and click on the Open device button. You should see the conversions running:

Hex string to ASCII characters conversion running in Cutecom

Drawing Letters in the Air

The DrawingInTheAir example currently has the following settings:

  • At least four drawing trials for each letters
  • Draw the letters A, B, C, D, E and F (A-F)
  • The sample rate is 200 Hz that is 200 X, Y and Z values per second
  • Each neuron can hold 128 bytes (vectorNumBytes variable)

Setup the board with the push button. The photo shows the Grove button plugged to the digital pin 4 (D4) on the Base Shield placed on top of the Arduino 101* (branded Genuino 101* in some countries).

Using the Grove button and base shield with Arduino 101*

Run the following commands in the main terminal:

$ cutecom &
$ export CODK_DIR=$(pwd)
$ cd $CODK_DIR/arc/libraries/Intel-Pattern-Matching-Technology/examples/DrawingInTheAir
$ make convert-sketch SKETCH=DrawingInTheAir.ino
$ make compile
$ make upload SERIAL_PORT=/dev/ttyACM0

You should see the following on the terminal window:

Confirmation of the DrawingInTheAir compilation

Wait for a few seconds and switch to the Cutecom terminal and click on the Open device button.  The program will prompt you to draw a letter, and will record the IMU data while the button is being held.

Capturing the letters A to F

When you draw a letter, the program converts the data into a suitable vector and uses the pattern matching engine to classify the vector by returning a category from 1 to 26, representing a letter from A to Z. Note that with the actual set of variables, the program should only consider the letters A to F, that is the categories 1 to 6.

Once you have drawn each letter A to F four times, the program takes you to the next step where you draw one of the six letters and the program displays the letter that has been recognized or the message "Don't recognize that one - - try again".

Capturing of letter is complete. Now draw some letters 

Run the program a few times in a raw until you master drawing the letters A to F in the air. Gradually you should get more letters recognized.

Getting your letters recognized by the PME

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.