Book Image

iOS Application Development with OpenCV 3

By : Joseph Howse
4 (1)
Book Image

iOS Application Development with OpenCV 3

4 (1)
By: Joseph Howse

Overview of this book

iOS Application Development with OpenCV 3 enables you to turn your smartphone camera into an advanced tool for photography and computer vision. Using the highly optimized OpenCV library, you will process high-resolution images in real time. You will locate and classify objects, and create models of their geometry. As you develop photo and augmented reality apps, you will gain a general understanding of iOS frameworks and developer tools, plus a deeper understanding of the camera and image APIs. After completing the book's four projects, you will be a well-rounded iOS developer with valuable experience in OpenCV.
Table of Contents (13 chapters)
iOS Application Development with OpenCV 3
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Saving an image to the Photos library


When the user presses the Save button, we start the busy mode. Then, if the video camera is running, we prepare to save the next frame. Otherwise, we immediately save the processed version of the static image. Here is the event handler:

- (IBAction)onSaveButtonPressed {
  [self startBusyMode];
  if (self.videoCamera.running) {
    self.saveNextFrame = YES;
  } else {
    [self saveImage:self.imageView.image];
  }
}

A helper method, saveImage:, is responsible for the transactions with the filesystem and Photos library. First, we try to write a PNG file to the application's temporary directory. Then, we try to create an asset in the Photos library based on this file. As part of this process, the file is automatically copied. We call other helper methods to show an alert dialog, which will describe the success or failure of the transaction. Here is the method's implementation:

- (void)saveImage:(UIImage *)image {
  
  // Try to save the image to a temporary...