Using Intel RealSense™ Technology in combination with the Intel Edison Development Platform

Using Intel RealSense™ Technology in combination with the Intel Edison Development Platform

Introduction

In the post mobile phone adoption world, we are now seeing the advent smart devices connected to things we never imagined, building a world some call the “Internet of Things”, or IoT. IoT devices are still in their infancy, with things from a watch with a pedometer to your car being turned on from your phone. The interesting part about IoT devices is that they can be equipped with a variety of low-cost sensors that can read temperature, humidity, heart rate, and so on not found on our phones or computers, making this information readily accessible for the first time in our lives. And with the Intel® Edison platform and Intel® Quark™ processors we can easily build prototypes that gather sensor information and create innovative products.

Another Intel innovation is Intel® RealSense™ technology. With the Intel RealSense 3D Cameras and SDK, applications can perform gesture detection, facial analysis, background segmentation, voice recognition, voice synthesis, and more, functioning almost like a super sensor that’s able to detect many things. Combined with the versatile uses of the Intel® Edison kit and its output, we can build many creative applications that are both useful and entertaining.

In this article are two examples of such applications, one using the Intel RealSense 3D Camera as input and the Intel® Edison board as output, the SDK triggers an LED light on the board. In the second example, which uses the Intel® Edison board as input and the Intel RealSense 3D Camera as output, voice synthesis is used to speak the sensor data from the board.

Hardware

  • Intel® Edison board with the Arduino* breakout board
  • Seeed Grove* – Starter Kit Plus – Intel® IoT Edition
  • 4th generation (or later) Intel® Core™ processor
  • 8GB free hard disk space
  • USB 3.0
  • An Intel® RealSense™ 3D Camera F200 (system-integrated or peripheral version)
  • (optional) Intel® NUC (Next Unit Computing) with a 4th generation Intel Core processor

Software

  • Arduino IDE: https://software.intel.com/en-us/articles/install-arduino-ide-on-intel-iot-platforms
  • Microsoft Visual Studio* 2010-2013 with service pack 1 or newer https://www.visualstudio.com/
  • Intel RealSense SDK https://software.intel.com/en-us/intel-realsense-sdk

What is the Intel® RealSense™ SDK?

The Intel RealSense SDK offers facial analysis, hand and finger tracking, voice recognition, voice synthesis, augmented reality object tracker, background segmentation, augmented reality and many more functionalities through a combination of hardware, software, and a 3D camera. The current SDK supports Microsoft .NET 4.0 framework, Unity* Pro 4.1.0 or higher, Processing* 2.2.1 or higher, and JDK 1.7.0_11 or higher. In our example, we’ll use .NET and C#.

Typical applications that can be developed with the Intel RealSense SDK include immersive collaboration, games, natural interaction, interactive storytelling, and Intel® Capture and Share, but these only scratch the surface of possibilities.
For more information about Intel RealSense technology, go to http://www.intel.com/content/www/us/en/architecture-and-technology/realsense-overview.html.

You can download the free SDK from https://software.intel.com/en-us/realsense/home/download.

A Closer Look at the Hardware

The Intel® Edison board is one of the first in a proposed series of low-cost, general-purpose compute platforms. It’s designed to allow for quick and easy prototyping of IoT projects while providing a product-ready path for commercialization.

The Intel® Edison board uses a 22nm dual-core Intel® Atom™ SoC running at 500MHz. It supports 40 GPIOs and includes 1GB LPDDR3 RAM, 4 GB EMMC for storage, dual-band Wi-Fi*, and Bluetooth*, all in a tiny form factor.

It runs a full Linux* kernel, and to get the best performance, you’ll want to write hardware-level Linux code.
In addition, the Intel® Edison board’s version of Linux contains an Arduino implementation as a Linux program. Simply put, this means you can write familiar Arduino sketches and run them on the board. And that’s exactly what we’ll do.
Learn more about the Intel® Edison board here: http://www.intel.com/content/www/us/en/do-it-yourself/edison.html

Arduino* Breakout Board

The Arduino breakout board serves two purposes. First, it provides a larger prototyping platform for easy access to the IO pins. And second, it provides an Arduino-compatible hardware platform, meaning we can use standard Arduino shields with the Intel® Edison board. Figure 1 shows the board mounted to the Arduino breakout board.

Intel® Edison board mounted to the Arduino* breakout board

Grove Starter Kit Plus

The kit’s full name is “Grove Starter Kit Plus – Intel® IoT Edition” and was originally designed for the Intel Galileo 2nd generation board. Fortunately, it’s fully compatible with Intel® Edison board via the Arduino breakout board.

The kit (shown in Figure 2) is designed to simplify working and prototyping with sensors, actuators, and shields. It contains an Arduino-compatible shield with standardized four (4) pin connectors. These connectors feed to the IO ports that connect with the included cables that also easily attach to the sensors and controls in the kit. This means you can build projects without needing to mess with small wires and pull-up/pull-down resistors, or worry about polarity.

Learn more or purchase the kit here: http://www.seeedstudio.com/depot/Grove-starter-kit-plus-Intel-IoT-Edition-for-Intel-Galileo-Gen-2-p-1978.html
The creator of the Grove Kit, Seeed Studios, has a number of useful resources online.

I recommend cloning or downloading the Sketchbook Starter repo here: http://Github.com/Seeed-Studio/Sketchbook_Starter_Kit_V2.0
And bookmark the Grove Wiki page here: 
http://www.seeedstudio.com/wiki/index.php?title=Main_Page#Grove

Grove Starter Kit Plus - Intel® IoT Edition

An Intel® RealSense™ 3D Camera F200

Either system-integrated or a peripheral version, Intel RealSense 3D Camera is built for game interactions, entertainment, photography, and content creation. The 3D camera is a complex sensor that, in a way, is part of IoT (after all, it’s named RealSense). The camera’s minimum requirements are a USB3, a 4th generation Intel® Core™ processor, and 8GB of hard drive space.

The camera (shown in Figure 3) features full 1080p color and an in-depth sensor and gives the PC a 3D vision and immersive experience.
You can purchase the complete developer kit, which includes the camera, at https://software.intel.com/en-us/realsense/devkit.

Intel® RealSense™ 3D Camera F200

Intel® Next Unit Computing (Intel® NUC) Powered by 4th Generation Intel® Core™ Processors or later

The Intel NUC is an optional device that can be used as a centralized hub for the Intel RealSense 3D Camera and the Intel® Edison module, as well as process additional functions such as storing and retrieving data to/from the cloud and performing further analysis on it. It is not required for development as you can connect the camera and the Intel® Edison breakout board kit through the USB serial port. However, if used, the information received from the camera can be processed and sent to the board to activate outputs such as alarms, motors, LEDs, etc. The information received from sensors on the board can be sent to the Intel NUC to activate voice synthesis using the Intel RealSense SDK.

As the camera requires USB3, 8GB RAM, and a 4th generation (or later) Intel Core processor, the Intel NUC (shown in Figure 4) easily meets these requirements. Another advantage is its user interface, with an HDMI port, making it easy to use as a computer if required. If you do not have a PC with the required software, an Intel NUC can be a relatively inexpensive option for owning one.

For more details on the Intel NUC, go to: http://www.intel.com/content/www/us/en/nuc/products-overview.html

Intel® NUC Powered by 4th Generation Intel® Core™ Processor

Installing the Software and Getting Ready to Code

We’ll be working with two code examples:
1. Capturing gestures from the Intel RealSense 3D Camera to control the LEDs on the Intel® Edison board.
2. Using data from the Intel® Edison board’s temperature sensor to activate Intel RealSense SDK voice synthesis.

Arduino IDE for Intel® IoT Platforms

You need to download the specially prepared version of the Arduino IDE in order to deploy Sketches to your board. The current version is 1.6.0 and is available here:

https://software.intel.com/en-us/articles/install-arduino-ide-on-intel-iot-platforms

Drivers for the Intel® Edison Board

You also need to download and install drivers for the Intel® Edison board from:
https://software.intel.com/en-us/iot/hardware/edison/downloads
It should be the last link on the page listed under “Driver Software.” The current version is 1.2.1.
For further instruction, refer to the Getting Started Guide:
https://software.intel.com/en-us/iot/library/edison-getting-startedVisual Studio
Visual Studio is a comprehensive collection of developer tools and services to help you create apps for the multiple platforms. The Intel RealSense SDK requires Visual Studio and Windows 8.1 as minimum software requirement. Visual Studio supports C, C++, VB.NET, C#, F#, M, Python*, Ruby, JavaScript* and many other languages. This specific guide uses C#.
You can download Visual Studio Express Edition for free. The commercial version of Visual Studio can be obtained at no cost through programs such as DreamSpark* for students and BizSpark* for startups.
You can find more information about Visual Studio at https://www.visualstudio.com/ and about C# athttps://msdn.microsoft.com/en-us/default.aspx

Intel® RealSense™ SDK

The Intel RealSense SDK allows developers to leverage 3D capabilities with the functionalities described earlier. The current version is 4.0.0.112526 (or the Gold R2 release) and is available here:

https://software.intel.com/en-us/intel-realsense-sdk/download

Testing the Intel® Edison Board

Before starting the walk-through below, please make sure you’re able to run the Blink example sketch. It’s included in the Arduino IDE download package in the examples -> 01.Basics -> Blink folder.
https://software.intel.com/en-us/blinking-led-with-arduino-ide-on-intel-edison-board

Installing Visual Studio* and the Intel® RealSense™ SDK

Installing Visual Studio should be very straight forward, the Intel RealSense SDK, however, requires a 3D Camera to be plugged into USB3 in order for it to install. You’ll know it’s been successfully installed when you see the Intel RealSense SDK Sample Browser (Figure 5) on your desktop, where you can browse through the C++ and C# examples. Camera-specific examples are also available; we’ll be using the Hand Viewer example.
The F200 Depth Camera Manager must be downloaded separately after installing the SDK. It is located at:
https://software.intel.com/en-us/intel-realsense-sdk/download.
Without the camera manager, the code samples will not initialize correctly.

Intel® RealSense™ Sample Browser

Example #1, Sending Signals from the Intel® RealSense™ 3D Camera to the Intel® Edison Board

For the first example we’ll build a simple app that uses hand gestures to send signals from the camera to control the LEDs on the board.

Code for the Intel® Edison Board

We’ll first have to build the receiving end of the code. We’ll connect the Grove kit to the Arduino breakout board and take the LED socket kit v1.3 and connect it to D2 as shown in Figure 6.

LED socket kit v1.3 connected to the Grove Kit D2 on the Arduino* expansion board

Connect the USB port to your PC or Intel NUC, use the Windows* Device Manager to find which serial port the Intel® Edison board is using. From Figure 7 we can see it is “COM16” in this case. Windows automatically detects the board and assigns the port when we connect the board to our PC.

Figure 7. Windows* Device Manager with the Intel® Edison Board’s Virtual Com Port

In the Arduino IDE under Tools, we’ll select “Intel® Edison” as the board and “COM16” as the Port as shown in Figures 8 and 9.

Board Selection in the Arduino* IDE

Figure 8. Board Selection in the Arduino* IDE

Port Selection in the Arduino* IDE

Figure 9. Port Selection in the Arduino* IDE
Finally, we get to do some programming. Since the board is used as an output device, the following few lines of code will control its serial port, where 1 turns on the light and 0 turns off the light.

01 const int ledPin = 2;     // the number of the pushbutton pin

02 void setup() {

03  // initialize the LED pin as an output:

04  pinMode(ledPin, OUTPUT);

05   Serial.begin(9600);

06 }

07
 

08 void loop() {

09  if (Serial.available()>0)

10   /* read the most recent byte */

11  {

12    int tmp = Serial.parseInt();

13    if(tmp == 0)

14   {

15  // turn LED off:

16    digitalWrite(ledPin, LOW);
  

17   }
 

18   else if (tmp == 1)
 

19    {

20  // turn LED on:
      

21  digitalWrite(ledPin, HIGH);
      

22    }

23  }

24 }

We are now finished with the code sample for the Intel® Edison board.

Code for the Intel® RealSense™ App

Under the C# F200 Samples, is the Hand Viewer app. Click the source on the right and open the RSSDK/FF_HandsViewer.cs folder. Copy this entire folder to the desktop so we can modify this project.

The specific gesture we are going to use is spread fingers. You can always switch to another gesture if you want. Figure 10 shows selecting the spreadfingers gesture for this example.

Intel® RealSense™ Hands Viewer

Under MainForm.cs modify and add the following code. The program is relatively simple, as we are simply declaring the serial port and tracking the last gesture. When the gesture is not the same, we change the flag for the LED. UpdateInfo is where existing sample code updates the user’s gesture. We can use the variable status to track whether the spreadfingers gesture is being given. When it is, we set the SerialPort’s flag to 1 and turn on the LED. When the gesture is finished, we send a 0 to the flag to turn off the LED.

01 using System.IO.Ports;

02 …

03  Public partial class MainForm : Form

04 {

05   private SerialPort _serialPort;
 

06 private int _lastGesture;

07    …

08 public MainForm(PXCMSession session)

09 {

10   …

11    _serialPort = new SerialPort();

12 _serialPort.PortName = "COM16"; //Serial port Edison is connected to

13  _serialPort.BaudRate = 9600;
          

14     _serialPort.ReadTimeout = 500;
       

15   _serialPort.WriteTimeout = 500;
         

16 }

17
 

18 private void WriteToSerialPort(int value)

19 {

20    if (_lastGesture != write)
        

21   {
         

22   Console.WriteLine(write.ToString());
             

23 _serialPort.Write(write.ToString());
               

24    }
        

25  _lastGesture = write;
          

26 }

27
 

28 public void UpdateInfo(string status,Color color)

29 {

30 …

31
 

32     if (status.Contains("spreadfingers") || status.Contains("spreadfingers"))
       

33   {
         

34    WriteToSerialPort(1);
            

35    }
        

36   else
         

37   {
         

38   WriteToSerialPort(0);
             

39  }      
             

40 }

41
 

42   private void Start_Click(object sender, EventArgs e)
     

43   {
     

44   …
         

45  _serialPort.Open();
          

46     }
   

47
 

48    private void Stop_Click(object sender, EventArgs e)
   

49    {
    

50   …
         

51    _serialPort.Close();
        

52   }
     

If everything works correctly, click the start button, place tracking to spread fingers. Then, when fingers are spread, the LED should light up as shown in Figure 11.

Using the spreadfingers gesture to light up the LED through the Intel® Edison board

Example #2, Reading data from the Intel® Edison Board and using an Intel® RealSense™ app for the output
In this example we use the temperature sensor connected to the Intel® Edison board as input and speech synthesis in an Intel RealSense app to make the sensor data more humanized.

Code for the Intel® Edison Board

The Grove* – Temperature sensor v1.1 is an analog sensor that we can plug in to A0 on the board through the Grove kit. The following Arduino code reads the temperature in Celsius. The code has a delay every 15 seconds so the text-to-voice portion through the speaker has time to complete. You can adjust the delay according to your needs. You can write additional logic to send out warnings when the temperature is too high or too low as well.

01 #include <math.h>

02 int a;

03 float temperature;

04 int B=3975;                  //B value of the thermistor

05 float resistance;

06
 

07 void setup()

08 {

09 Serial.begin(9600); 

10 }

11
 

12 void loop()

13 {

14  a=analogRead(0);

15  resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor;

16  temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;//convert to temperature via datasheet ;

17  Serial.print("Current temperature is ");

18  Serial.print(temperature);

19  Serial.println(" celcius");

20
 

21  delay(15000);

22 }

The Intel® RealSense™ App

Under Common Samples you’ll see Speech Synthesis. Copy the source folder “ambitious, persistence, resilient risk taker,” just like we did in the previous Hand Viewer example. The interface might not change, but the goal is to use speech synthesis to speak the sensor data from the board. We are still using “COM16”.
Change the MainForm.cs file as follows:

01 using System.IO.Ports;

02 …

03 public partial class MainForm : Form

04 {

05    private SerialPort _serialPort;
    

06  private static bool _continue;
      

07    protected static string curr_module_name;
    

08  protected static uint curr_language;
      

09  protected static int curr_volume;
      

10   protected static int curr_pitch;
     

11   protected static int curr_speech_rate;
     

12
 

13  Thread readThread = new Thread(Read);
      

14
 

15  static public void Read()
      

16  {
      

17   while (_continue)
         

18  {
          

19   try
             

20   {
             

21   string message = _serialPort.ReadLine();
                 

22  Console.WriteLine(message);
                  

23  Voice Synthesis.Speak(curr_module_name, (int)curr_language, message, curr_volume, curr_pitch, curr_speech_rate);
                  

24     }
           

25   catch (TimeoutException) { }
             

26   }
         

27   }
     

28
 

29   public MainForm(PXCMSession session)
     

30   {
     

31  …
          

32   _serialPort = new SerialPort();
         

33  _serialPort.PortName = "COM16"; //Serial port Edison is connected to
          

34   _serialPort.BaudRate = 9600;
         

35  _serialPort.ReadTimeout = 500;
          

36   _serialPort.WriteTimeout = 500;
         

37
     

38  _serialPort.Open();
          

39    _continue = true;
        

40    readThread.Start();
        

41    }
    

42   private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
     

43   {
     

44     _continue = false;
       

45  readThread.Join();
          

46  _serialPort.Close();
          

47   }
     

48  …  
      

49 }

If everything runs correctly, the program will speak the temperature sensor data every 15 seconds. Feel free to modify the program for your individual needs, such as changing the interface or simply copy Voice Synthesis.cs and VoiceOut.cs into your own project.

Going Forward

I hope these two examples help developers and entrepreneurs to expand their thinking and come up with more ideas that utilize the power of both technologies. One prototype I came up with was Anti-Snoozer, where the Intel RealSense 3D Camera detects when a driver is getting drowsy and sends alarms through the Intel Edison board to give additional warnings to wake the driver up. Thousands of combinations of using the power of both technologies are possible. So, what will you make?

For more such intel IoT resources and tools from Intel, please visit the Intel® Developer Zone

Source: https://software.intel.com/en-us/articles/using-intel-realsense-technology-in-combination-with-the-intel-edison-development-platform

Promotion
Digit.in
Logo
Digit.in
Logo