Introduction

Google Glass is a wearable computer developed by Google. Although Glass is based on Android, it is fundamentally different from existing mobile platforms. The best line to describe Glass is “There when you need it. Out of the way when you don’t.” Glass is designed to complement a smartwatch, smartphone, tablet, or computer.

In April 2013, the Google Glass Explorer Edition was made available, for the first time, to Google I/O 2013 developers. There were four Glass-related sessions at Google I/O 2013 held in May 2013:

Since then, several important events have happened:

  • On November 19, 2013, Google officially released the native Android-based Glass Development Kit (GDK) Sneak Peek, so developers can now build native apps in Android 4.0.4 (API Level 15) for Glass.
  • On April 15, 2014, Google announced a major upgrade for Glass to Android 4.4.2 (API Level 19).
  • On May 15, 2014, Google made the Glass Explorer Edition available to any U.S. resident older than 18 and with a U.S. shipping address.

It is almost mid-June 2014 now, and Google I/O 2014 is only a couple of weeks away. More Glass-related sessions on how to design and develop Glass apps (also known as Glassware) and on the Glass platform details have been scheduled (see https://www.google.com/events/io/schedule).

This is a great time to start learning Glass development; if you need more reasons, see the “Why Glass?” section in Chapter 1. You should definitely check out those Google I/O 2013 and 2014 videos on Glass if you are interested in Glass development. In addition, Google Glass’s developer site at https://developers.google.com/glass/ has great documentation on designing, developing, and distributing for Glass. But none of this compares to having step-by-step tutorials with working code examples on every major Glass development topic, using both GDK and the Mirror API. That is exactly what this book is provides.

What’s in This Book

There are ten chapters in this book, covering every major Glass development topic.

Chapter 1, “Getting Started”: In this chapter, I’ll discuss several general topics about Glass and Glassware: Why Glass? What is Glass and Glassware? What can you do with GDK Glassware and Mirror Glassware? Why this book? Who is the book for? I’ll also list popular Glass development web resources.

Chapter 2, “Hello, Glass! Your First GDK App”: I’ll first cover the detailed steps of how to set up your GDK Glassware development environments, whether your favorite is Mac, Windows, or Linux. Then I’ll discuss how to set up Glass to get it ready for development and how to run sample GDK apps on it. Finally, I’ll introduce the generic template Glassware, which you’ll use to create new GDK apps, and show you a step-by-step tutorial of building HelloGlass, your first GDK app, with nice features such as menu actions, text-to-speech, and speech-recognition versions of HelloGlass.

Chapter 3, “Glass User Interface”: In this chapter, you’ll enter the exciting world of Glass and learn what kinds of UI elements can be built with GDK for a Glass app. The main Glass UI elements—the timeline, Glass-styled cards, live cards, immersions, menu items, and gestures—will be discussed in detail with fully tested sample code that shows you how to render standard UI content, content from an XML layout, and content created using Android’s Canvas 2D and OpenGL ES 1.0 and 2.0. By end of this chapter, you’ll have a basic understanding of what kinds of apps you can build with GDK and when to use which or a combination of them.

Chapter 4, “Camera and Image Processing”: In this chapter, you’ll start with how to use the Glass camera to take pictures, both in the easy way and in the custom way, which allows you to preview and zoom before taking a picture. Then I’ll briefly cover how to browse the photos in any directory of your Glass. After that, I’ll discuss step-by-step many common practical image-processing tasks, including barcode and QR code recognition, OCR, image web search, and OpenCV. I’ll cover how to integrate the best open source libraries out there, if needed, to your own app and how to call their APIs from within your app. By the end of this chapter, you’ll be well prepared for exploring your own great app ideas using all kinds of image-processing techniques.

Chapter 5, “Video: Basics and Applications”: In this chapter, you’ll start with the basic video capture and custom video capture with preview and then look at how video can play on Glass. Then I’ll discuss how to use OpenCV to add image effects on frames extracted from video. A more powerful video-processing library, FFmpeg, will be introduced with detailed instructions of how to integrate it with your own app. Commands for various video filtering effects will be presented. Finally, a YouTube video search and play app will be covered in detail, which can be used as the foundation of a full-fledged karaoke app.

Chapter 6, “Voice and Audio”: In this chapter, I’ll cover a lot of voice- and audio-related topics, from the standard Glass voice input, both high-level and low-level audio capture and playback, to various audio-processing examples, including musical note detection, DTMF touchtone detection, and, finally, song identification. Voice and audio are essential parts of our communication with each other and with devices, so you can expect to see many innovative apps in this area, developed by people like you.

Chapter 7, “Networking, Bluetooth, and Social”: In this chapter, I’ll first cover how to implement the basic HTTP GET, POST, and file uploading operations using the recommended HttpURLConnection class. Then I’ll discuss how to accomplish low-level socket programming and let Glass talk with another Android or iOS device for data exchange, both as a client and as a server. After that, I’ll illustrate in detail how to use Classic Bluetooth for communication between Glass and another Android device, without the need of wi-fi. I’ll then introduce the exciting topic of BLE support and how to let Glass act as a BLE client and also how to use the Samsung Galaxy S4 smartphone or an iOS device as a bridge between Glass and BLE devices. Finally, I’ll show you how to use Apple’s push technology to let you share your new picture taken on Glass with your WhatsApp or WeChat friends in seconds.

Chapter 8, “Location, Map, and Sensors”: In this chapter, I’ll discuss in detail how to get your current location and show its address and map, how to zoom in and out the map, and how to find nearby business information based on your location information. Then I’ll cover the eight sensors Glass supports and how to detect head movement and direction, how to detect Glass shake, how to develop a metal detector, and how to add the compass support easily to your app. Finally, I’ll outline the steps to build a planet-finder Glass app.

Chapter 9, “Graphics, Animation, and Games”: In this chapter, I’ll cover common graphics and animation APIs and show many demos running on Glass, which you can use in your own simple Glass apps. Then I’ll discuss in great detail how to set up and run three popular open source game engines (Cocos2d-x, libgdx, and AndEngine) on Glass. You’ll learn how to run and interact with many examples for the three game engines, as well as how to create new apps using the engines. Finally, you’ll learn how to use the Glass rotation vector sensor to control your game with head movement. By the end of this chapter, you’ll be well armed with these powerful tools before you continue your own exciting game development journey.

Chapter 10, “The Mirror API”: In this chapter, I’ll discuss in detail how to set up your environment for Mirror API app development and how to deploy the Glass Mirror API quick-start PHP project to your own server and the Java project to Google App Engine. Then I’ll go through the main building blocks of the Mirror API in detail with many examples, including timeline and static cards, contacts, subscriptions, and locations. I’ll also show you how to build a hybrid app launching the GDK app from the Mirror app and pass information from the Mirror app to the GDK app if needed. You’ll also reuse the Java image-uploading code from Chapter 7 in your Mirror app to upload a picture to a server for further processing. Finally, I’ll demonstrate a complete Mirror API app that lets you view and search for any player in the 16 NBA playoff teams.

Before Getting Started

I actually wrote this Introduction after I finished writing the book. It took me about six long months of weekday evenings and weekends to learn and get up to speed on the GDK and Mirror API, to develop and test dozens of examples that illustrate what Glass can truly do (as summarized in the previous section), to write step-by-step tutorials on how to run and use the examples, and to review and fix any known issues.

No matter what your background and interests are, there should be some examples in the wide range of Glass development topics covered in the book that will inspire you and help you have a quick start on developing your own great Glass apps. I hope the hundreds of hours I spent on the book will save you a lot of time when developing for the exciting Glass platform.

Have a wonderful trip in the Glass development world! If you have any questions or comments on the trip, just email me anytime at [email protected], and you’ll receive my response within 24 hours.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.233.135