Book Image

Instant OpenCV for iOS

4 (1)
Book Image

Instant OpenCV for iOS

4 (1)

Overview of this book

Computer vision on mobile devices is becoming more and more popular. Personal gadgets are now powerful enough to process high-resolution images, stitch panoramas, and detect and track objects. OpenCV, with its decent performance and wide range of functionality, can be an extremely useful tool in the hands of iOS developers. Instant OpenCV for iOS is a practical guide that walks you through every important step for building a computer vision application for the iOS platform. It will help you to port your OpenCV code, profile and optimize it, and wrap it into a GUI application. Each recipe is accompanied by a sample project or an example that helps you focus on a particular aspect of the technology. Instant OpenCV for iOS starts by creating a simple iOS application and linking OpenCV before moving on to processing images and videos in real-time. It covers the major ways to retrieve images, process them, and view or export results. Special attention is also given to performance issues, as they greatly affect the user experience.Several computer vision projects will be considered throughout the book. These include a couple of photo filters that help you to print a postcard or add a retro effect to your images. Another one is a demonstration of the facial feature detection algorithm. In several time-critical cases, the processing speed is measured and optimized using ARM NEON and the Accelerate framework. OpenCV for iOS gives you all the information you need to build a high-performance computer vision application for iOS devices.
Table of Contents (7 chapters)

Preface

Instant OpenCV for iOS is a practical guide, showing every important step for building a computer vision application for the iOS platform. It will help you to port your OpenCV code, profile and optimize it, and then wrap into a GUI application. This book helps you to learn how to build a simple, but powerful computer vision application for the iOS devices from scratch. Throughout the book, you'll learn details that will help you to become a professional at iOS development using OpenCV. As usual, you begin with the simple "Hello World" application, but finally you will be able to create complex image processing applications with supreme efficiency.

Each recipe is accompanied with a sample project, helping you to focus on a particular aspect of the technology.

What this book covers

  • Getting started with iOS (Simple), helps you to set up your development environment and run your first "Hello World" iOS application.

  • Displaying an image from resources (Simple), introduces you to basic GUI concepts on iOS, and covers loading of an image from resources and displaying it on the screen.

  • Linking OpenCV to an iOS project (Simple), explains how to link OpenCV library and call any function from it.

  • Detecting faces with Cascade Classifier (Intermediate), shows how to detect faces using OpenCV.

  • Printing a postcard (Intermediate), demonstrates how a simple photo effect can be implemented.

  • Working with images in Gallery (Intermediate), explains how to load and save images from/to Gallery.

  • Applying a retro effect (Intermediate), demonstrates another interesting photo effect that makes photos look old.

  • Taking photos from camera (Intermediate), shows how to capture static images with camera.

  • Creating a static library (Intermediate), explains how to create a static library project in Xcode.

  • Capturing a video from camera (Simple), shows how to capture a video stream from camera.

  • Control advanced camera settings (Advanced), explains how to control advanced camera settings, such as exposure, focus, and white balance.

  • Applying effects to live video (Intermediate), shows how to process captured video frames on the fly.

  • Saving video from camera (Simple), explains how to save video stream to the device with hardware encoding.

  • Optimizing the performance with ARM NEON (Advanced), explains how to use SIMD instructions to vectorize your code and improve the performance.

  • Detecting facial features (Advanced), presents a simple facial feature detection demo.

  • Using the Accelerate framework (Advanced), explains how to link the framework, and how to use it for performance optimization.

  • Building OpenCV for iOS from sources (Advanced), explains where to get and how to build the latest OpenCV sources.

What you need for this book

In order to be able to build and run sample projects from this book, you will need a Mac OS X computer, as it is the only supported way to develop for iOS platform. You should also have a device with iOS 6.0 or higher, because Simulator doesn't support camera, and some projects will not work on it.

Finally, you need the latest version of Xcode, so you can modify, build, and execute examples from this book.

Who this book is for

This book is intended for OpenCV developers who are interested in porting their applications to the iOS platform. You need to have some basic experience with OpenCV and computer vision, but can be a beginner in Objective-C or other iOS tools. The book could be also helpful for those who are familiar with iOS and want to add some image processing or computer vision functionality to their projects.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The NSLog function, which we added first, is intended for logging simple text messages, similar to the printf function in the C language."

A block of code is set as follows:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // Read the image
    image = [UIImage imageNamed:@"lena.png"];
    if (image != nil)
        imageView.image = image;
}

Any command-line input or output is written as follows:

$ cd /
$ sudo ln -s /Applications/Xcode.app/Contents/Developer Developer

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "As we know the resolution of the camera only after session starts, we should create a filter object when the StartCapture button is clicked".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.