Beginning Google Glass Development - Jeff Tang.pdf

(9577 KB) Pobierz
TECHNOLOGY IN ACTION
™
Beginning
Google Glass
Development
START DEVELOPING GOOGLE GLASSWARE TODAY!
Jeff Tang
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance
About the Author ...............................................................................................................xiii
About the Technical Reviewer ............................................................................................
xv
Acknowledgments ............................................................................................................
xvii
Introduction .......................................................................................................................
xix
Chapter 1: Getting Started .................................................................................................1
Chapter 2: Hello, Glass! Your First GDK App ....................................................................13
Chapter 3: Glass User Interface .......................................................................................47
Chapter 4: Camera and Image Processing ......................................................................81
Chapter 5: Video: Basics and Applications ....................................................................113
Chapter 6: Voice and Audio ...........................................................................................147
Chapter 7: Networking, Bluetooth, and Social ...............................................................175
Chapter 8: Location, Map, and Sensors .........................................................................215
Chapter 9: Graphics, Animation, and Games .................................................................249
Chapter 10: The Mirror API ............................................................................................297
Index .................................................................................................................................337
v
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:
n
n
n
n
Developing for Glass:
https://developers.google.com/events/io/sessions/332490621
Building Glass Services with the Mirror API:
https://developers.google.com/events/io/sessions/332733833
Voiding Your Warranty: Hacking Glass:
https://developers.google.com/events/io/sessions/332704837
Fireside Chat with the Glass Team:
https://developers.google.com/events/io/sessions/332695704
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.
Since then, several important events have happened:
n
n
n
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).
xix
xx
Introduction
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.
Zgłoś jeśli naruszono regulamin