Mastering Raspberry Pi AI Service Development with Microsoft

Mastering Raspberry Pi AI Service Development with Microsoft

This article is from the author Microsoft Open Course shared on GitChat with the topic “Easily Master Raspberry Pi AI Service Development in 60 Minutes”

Editor | Mc Jin

Author:

Shi Jiong, Director of Internet of Things Engineering Department at Zhejiang Wanli University, Master’s supervisor, author of “Windows IoT Application Development Guide”, specializes in Microsoft terminal and Azure IoT related application development, active in Blog Garden, Microsoft Chinese Official Forum, and Hackster.io communities, and has been awarded Microsoft Most Valuable Professional (MVP) for nine consecutive years.

1. Introduction

Currently, the Internet of Things and artificial intelligence have penetrated various fields such as healthcare, home, transportation, education, and industry, greatly changing people’s daily lives.

The Raspberry Pi is popular among many IoT technology enthusiasts and makers. In addition to the official Raspbian system, it can also run Microsoft’s Windows 10 IoT Core and Google’s Android Things, which are operating systems aimed at IoT applications.

Microsoft Cognitive Services integrates various intelligent APIs and knowledge APIs, capable of running on multiple platforms such as Windows, Linux, and Mac.

With these APIs, developers can create products that can see, hear, speak, and understand human needs conveyed through natural communication methods, thus creating smarter and more engaging products.

This Chat will introduce how to develop Microsoft Cognitive Services on Raspberry Pi running Windows 10 IoT Core, mainly covering the following content:

  1. Getting Started with Windows IoT: Windows IoT running platform, development environment setup, and system flashing.

  2. Introduction to Microsoft Cognitive Services: Classification of Microsoft Cognitive Services, creation of Microsoft Cognitive Services.

  3. Developing Cognitive Services based on Windows IoT: Hardware resources required for running cognitive services on Windows IoT, development of computer vision services, development of face recognition services, development of emotion recognition services.

2. Getting Started with Windows IoT

2.1 Windows IoT Running Platform

Since Windows 10, Microsoft has made significant changes to its product planning for operating systems, unifying the naming of operating systems for tablets, PCs, motion sensing, gaming, and IoT devices as Windows 10 operating system. At the same time, for the new platform, a model of “Universal Applications” has been launched, achieving the goal of a single project that is universal across all platform devices.

For the IoT application field, Microsoft has launched the Windows IoT product line. Currently, Windows 10 IoT is divided into two branches: one is Windows 10 IoT Core, and the other is Windows 10 IoT Enterprise, targeting small IoT applications and enterprise-level IoT applications, respectively.

The running platform for this project is Windows 10 IoT Core, which supports a series of SoCs from Intel, Qualcomm, and Broadcom, covering ARM and x64 product lines, and can be deployed to nearly 60 types of boards.

Among them, commonly available boards in the market include Raspberry Pi (ARM), DragonBoard 410c (ARM), MinnowBoard MAX (x64), and Intel Compute Stick (x64). Comparatively, the best cost-performance ratio is undoubtedly the Raspberry Pi.

Currently, the Raspberry Pi models that can run Windows 10 IoT Core are Raspberry Pi 2B and Raspberry Pi 3B. The latest Raspberry Pi 3B+ is not yet supported but has been included in the Windows 10 IoT Core support list, and it is believed that Microsoft will soon develop the corresponding FFU.

For more information about devices running Windows 10 IoT Core, please refer to the following link: Windows 10 IoT Core Device List.

2.2 Environment Setup

Currently, the only tool that supports Windows 10 IoT Core development is the free Visual Studio 2017 Community version. Of course, Visual Studio 2015 Community also supports application development for earlier Build models (before 15063), but it is still recommended to install Visual Studio 2017.

When installing Visual Studio 2017 Community version, please check the option for Universal Windows Platform development.

Additionally, for friends who want to use C++ to develop applications, it is also necessary to check the option for C++ Universal Windows Platform tools. As shown in Figure 1.

Mastering Raspberry Pi AI Service Development with Microsoft

Figure 1: Visual Studio 2017 Installation Options

2.3 Flashing the Windows 10 IoT System

For Raspberry Pi, its system is flashed on an external SD card. Microsoft provides a graphical system flashing software called Windows 10 IoT Core Dashboard. Users can download it from the following link: http://go.microsoft.com/fwlink/?LinkID=708576

For the SD card selection, it is recommended to use high-speed SD cards, such as Samsung 32GB EVO Class 10 Micro SDHC and SanDisk Ultra Micro SDHC 16GB.

After installing Windows 10 IoT Core Dashboard, insert the SD card into the card reader and the card reader into USB to begin the system flashing. Its interface is shown in Figure 2.

Mastering Raspberry Pi AI Service Development with Microsoft

Figure 2: Windows 10 IoT Core Dashboard Interface

In the device type, select Raspberry-Pi, and for the OS version, you can choose between Release and Insider Build. It is recommended to select the Release version.

Set the device name and administrator password, and you can download and flash the system to the SD card. After the system is flashed, you can remove the SD card, insert it into the Raspberry Pi, and prepare to power on the Raspberry Pi to run.

2.4 Peripheral Devices for Raspberry Pi

To operate normally, the Raspberry Pi requires the following peripheral devices:

(1) Power supply: 5V/2.5A power supply, Micro USB interface.

(2) Display device: A monitor that can connect to HDMI, or using an active HDMI to VGA module to connect to a VGA monitor. It is important to note that an active HDMI to VGA module must be used; otherwise, video signals cannot be output to the monitor.

(3) Mouse and keyboard: USB mouse and keyboard can be used, and most brands support this.

(4) Camera: Currently, among the official cameras, only USB interface cameras are supported, such as Microsoft Lifecam 3000, Microsoft Lifecam HD-5000, and Microsoft® LifeCam Studio.

Note that the official CSI interface camera from Raspberry Pi is not supported by Windows 10 IoT Core.

For the models of peripheral devices supported by Windows IoT Core, please refer to the official documentation: hardware compatible list.

3. Microsoft Cognitive Services

3.1 Classification of Microsoft Cognitive Services

Microsoft Cognitive Services (Cognitive Service) is part of its AI platform, which originated from Project Oxford. In May 2015, Microsoft officially released Project Oxford, which includes three parts of APIs: face recognition, speech processing, and computer vision.

After nearly three years of development, Project Oxford has been renamed Cognitive Services, which includes five major categories of services: image, speech, language, knowledge, and search, covering eight subfields of APIs including computer imaging, face recognition, Bing speech, speaker recognition (preview), Bing spell, text analysis, custom decision services (preview), and Bing search. The cognitive services focused on in this Chat mainly include APIs for computer vision and face recognition.

3.2 Creation of Microsoft Cognitive Services

Currently, Microsoft has hosted Cognitive Services on the Azure platform. For users who want to try it, Microsoft provides a one-month free trial opportunity for developers.

Therefore, two different methods for creating cognitive services will be introduced here. Method one is for users with Azure subscriptions, and method two is for users on a free trial.

3.2.1 For Azure Subscription Users

First, for users with MSDN subscriptions, you can log into the Azure portal. Click on “Create a resource,” and in the search bar, enter “Computer Vision API” to search. Then click “Create” to create it, specifying the name of Computer Vision, location (East Asia), and tier (here we can choose the free level F0, which includes 5000 transactions per month).

Further pricing information can be found at the official link: Cognitive Services Pricing – Computer Vision API. After the Computer Vision Service is created, you can click on the Keys property in the resource and copy KEY 1 to your local machine, which we will use in the subsequent UWP application. As shown in Figure 3.

Mastering Raspberry Pi AI Service Development with Microsoft

Figure 3: Computer Vision Properties Page

Next, using the same method, create the Face API service in the Azure Portal. Note that the emotion recognition (Emotion API) service we will use later has completed its preview version and has officially merged into the Face API service.

Therefore, it is only necessary to create the Face API resource to complete face and emotion recognition. After the Face API Service is created, you can click on the Keys property in the resource and copy KEY 1 to your local machine, which we will use in the subsequent UWP application. As shown in Figure 4.

Mastering Raspberry Pi AI Service Development with Microsoft

Figure 4: Face API Properties Page

For Trial Users

If you do not have an Azure subscription, you can try Microsoft Cognitive Services for free through the following method, with a trial time limit of one month. Users first navigate to the official cognitive services trial page: https://azure.microsoft.com/zh-cn/try/cognitive-services/?api=computer-vision

Select the service you want to try from the list, for example, here we choose Computer Vision (Computer Vision API), as shown in Figure 5.

Mastering Raspberry Pi AI Service Development with Microsoft

Figure 5: Cognitive Services Trial Page

Then, select China for the country and region, and log in using any of your Microsoft account, LinkedIn account, Facebook account, or GitHub account to create. After that, remember to generate the API KEY and copy it to your local machine, as shown in Figure 6.

Mastering Raspberry Pi AI Service Development with Microsoft

Figure 6: Cognitive Services API KEY Page

Next, generate the KEY for the Face API in the same way and copy it to your local machine.

Thus, we have completed the creation of Microsoft Cognitive Services, generated the required API KEY, and saved it locally to prepare for subsequent UWP application development.

4. Development of Cognitive Services Based on Windows IoT

4.1 Hardware Resources Required for Running Cognitive Services on Windows IoT

This project uses Raspberry Pi. If it is only for recognizing images stored locally on the Raspberry Pi, then a camera is not needed. In most application scenarios, real-time image capture and recognition require camera support.

As mentioned earlier, currently Windows IoT Core only supports USB interface cameras such as Microsoft Lifecam 3000, Microsoft Lifecam HD-5000, and Microsoft® LifeCam Studio.

Note that the official CSI interface camera from Raspberry Pi is not supported by Windows 10 IoT Core.

Additionally, Microsoft Lifecam 3000 already includes a microphone, which can also perform voice-related cognitive services.

Scan the QR code below

[Read the full original text]

And communicate with the author in the reader circle

Mastering Raspberry Pi AI Service Development with Microsoft

Leave a Comment

Your email address will not be published. Required fields are marked *