Pro iOS 5 Augmented Reality Copyright © 2011 by Kyle Roche This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher's location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN-13 (pbk): 978-1-43023912-3 ISBN-13 (electronic): 978-1-4302-3913-0 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. President and Publisher: Paul Manning Lead Editor: Kate Blackham Technical Reviewer: Yosun Chang, Peter Ma, Graham Wood Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Morgan Ertel, Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh Coordinating Editor: Corbin Collins Copy Editor: Vanessa Moore Compositor: MacPS, LLC Indexer: BIM Indexing & Proofreading Services Artist: SPi Global Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800- SPRINGER, fax (201) 348-4505, e-mail http://[email protected], or visit www.springeronline.com. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com. For detailed information about how to locate your book's source code, go to www.apress.com/source- code/. Contents at a Glance Contents About the Author About the Technical Reviewers Acknowledgments Preface Chapter 1: Introduction Chapter 2: Hardware Comparison Chapter 3: Using Location Services Chapter 4: iOS Sensors Chapter 5: Sound and User Feedback Chapter 6: Camera and Video Capture Chapter 7: Using cocos2D for AR Chapter 8: Building a cocos2D AR Game Chapter 9: Third-Party Augmented Reality Toolkits Chapter 10: Building a Marker-Based AR Application with OpenGL ES Chapter 11: Building a Social AR Application Chapter 12: Facial-Recognition Techniques Chapter 13: Building a Facial Recognition AR App Index Contents Contents at a Glance About the Author About the Technical Reviewers Acknowledgments Preface Chapter 1: Introduction Augmented Reality in the Real and Cyber World Pop Culture Gaming and Location-Based AR Getting Your House in Order Signing Up for GitHub Accessing GitHub from Your Machine Setting Up Xcode 4.2 and Your Developer Account Linking an Xcode Project to GitHub Creating Our Xcode Project Connecting Our Project to the Remote Repository What's Next? Location Services Sensor Programming Lights, Camera, Action … Gaming Frameworks Third-Party Frameworks Summary Hardware Comparison Out with the Old Hardware Components Camera Support Detecting Location Capabilities Wired for Sound Checking for Video Capabilities Acceleration and Gyroscope Enforcing Hardware Requirements Summary Using Location Services You Are Here Standard Location Service Significant-Change Location Service Geographic Region Monitoring Service Altitude Viewing on the Map Centering the Map and Setting the Displayed Region Changing the Map Type Adding Annotations to the Map Reverse Geocoding Summary iOS Sensors Orientation Sensors Using the Accelerometer Low-Pass Filtering Using the Gyroscope Magnetometer Summary Sound and User Feedback Audio Data Formats So, Which Data Format Is for Me? What About File Formats? Bit Rates and Quality Sample Rates Converting Audio for Use in iOS Playing Sound in an iOS Application System Sound Services AVAudioPlayer Class Experimenting with the Multiple Audio Players Playing Positional Sound User Feedback Through Vibration Recording Sound Initializing the Audio Recorder Summary Camera and Video Capture Quick Review Photo Capture Using Storyboards Using the Camera Saving Images in Different Formats E-mailing an Image Video Capture Building a Base on the Video Preview Building a Base for Frame Capture sSummary Using cocos2D for AR Overview Installation Installing the Project Templates Creating a Project Hello Augmented World Adjusting the Default View Adding the Camera View Scaling the Camera View cocos2D Concepts Scenes Director Layers Adding Effects Handling Touch Events Visual Effects Adding Sound Effects Adding a HUD Layer Summary Building a cocos2D AR Game Overview Creating the Project Camera View Creating the Game Menu Artwork Helper Code Directory Finishing the Menu Screen Adding the Menu Option Enable Camera Support Finishing the Action Layer Here Come the Pumpkins Ending the Game Summary Third-Party Augmented Reality Toolkits Overview Powered by String String's Basic Workflow Extra Functionality Unity Integration Advanced Shaders and OpenGL Features Qualcomm SDK Building Our Own QCAR Demo Creating the Xcode Project EAGLView Redirecting the UIView ARKit Summary Building a Marker-Based AR Application with OpenGL ES Building a Marker Our Marker OpenGL ES Creating the Project Adding the String SDK EAGLView Creating the AR ViewController Summary Building a Social AR Application Getting Set Up Creating a Facebook Application Cloning the Facebook iOS SDK Vocabulary Lesson Azimuth Corrected Heading Building the Application Credits Required Frameworks Adding the Facebook iOS SDK And, We're Off! Listening for Sensor Updates Storing Coordinates Adding Social Context Graph for Friends Summary Facial-Recognition Techniques Choices for Facial Recognition OpenCV iOS 5 CIDetector Class Face.com Using the OpenCV Approach Capturing the Image for Testing Haar Cascades OpenCV Review Using the CIDetector Class Approach CIDetector Review Using the Face.com API Approach Faces.detect API Call Adding Face.com Support to Our Sample Face.com API Key Adding the Face.com Callout Measuring Performance Summary Building a Facial Recognition AR App The Application’s Purpose Technology Used Getting Set Up
Description: