Code Monkey home page Code Monkey logo

opencv_for_ios_book_samples's Introduction

OpenCV for iOS (samples for the book)

Build & run sample projects

Almost every chapter of the book describes a separate project. There are 15 Xcode projects for 17 chapters in the book. Chapter 16 extends the project of Chapter 14, and for Chapter 17 you need only OpenCV source code.

  • First of all you will need a computer with Mac OSX and Xcode. An iOS device is also helpful, since not all samples can be executed on Simulator.
  • Install OpenCV v2.4.6 or newer. You can go to http://opencv.org, click on Downloads, and download the latest OpenCV framework for iOS. Copy it to the folder with this code.
  • Now you can import sample projects to Xcode and run them on Simulator or a real device.

For detailed instructions and explanations please refer to the book.

Chapters

  1. Getting Started with iOS helps you to setup your development environment and run your first "Hello World" iOS application.
  2. Displaying Image from Resources introduces you to basic GUI concepts on iOS, and covers loading of an image from resources and displaying it on the display.
  3. Linking OpenCV to iOS Project explains how to link OpenCV library and call any function from it.
  4. Detecting Faces with Cascade Classifier shows how to detect faces using OpenCV.
  5. Printing Postcard demonstrates how a simple photo effect can be implemented.
  6. Working with Images in Gallery explains how to load and save images from/to Gallery.
  7. Applying Retro Effect demonstrates another interesting photo effect, which makes photos look old.
  8. Taking Photos From Camera shows how to capture static images with camera.
  9. Creating Static Library explains how to create a Static Library project in Xcode.
  10. Capturing Video from Camera shows how to capture video stream from camera.
  11. Control Advanced Camera Settings explains how to control advanced camera settings, like exposure, focus and white balance.
  12. Applying Effects to Live Video shows how to process captured video frames on the fly.
  13. Saving Video from Camera explains how to save video stream to the device with hardware encoding.
  14. Optimizing Performance with ARM NEON explains how to use SIMD instructions to vectorize you code and improve performance.
  15. Detecting Facial Features presents a simple facial feature detection demo.
  16. Using Accelerate Framework explains how to link the framework, and how to use it for performance optimization.
  17. Building OpenCV for iOS from sources explains where to get and how to build the latest OpenCV sources.

Screenshots

Chapter 5. "Printing Postcard"

Chapter 6. "Working with Images in Gallery"

Chapter 7. "Applying Retro Effect"

Chapter 12. "Applying Effects to Live Video"

Chapter 15. "Detecting Facial Features"

opencv_for_ios_book_samples's People

Contributors

alekcac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencv_for_ios_book_samples's Issues

Repeatedly Start Camera and Stop camera causes crash

I'm running the samples and samples Chap 14 and 15 will crash usually after stopping camera capture then hitting start once. Sometimes it doesnt crash until 5th cycle. I've been googling this issue but haven't came up with a solution.

Strange issue

I am new to Xcode for ios. I encountered a very strange problem.

My Xcode is 7 under MacOS EI. and I download the this opencv samples for ios
And after that I downloaded the opencv2.framework 2.4.9 for ios not Mac (they are different).

but, after I unzipped the opencv2.framework, the folders' names are very strange. There is no FOLDER named "opencv2" but "Headers". If so, how could I find the correct path????

In addition, where is the shared library? the next to that file is named "opencv2" but without any suffix. I do not know what it is. maybe the shared library.

In order to make the paths correct, I have changed the "*.h" files folder name to be "opencv2", so the project can find the header files. But still can not link to the library. The error is as follows.

ld: framework not found opencv2 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Although I have set the search path for headers and library.

I have searched a lot but no answers, Could you please give some ideas??

Thank you in advance!

Error with function copyTo() and mask

Enviroment

Ubuntu 18.04
OpenCV
C++

Content

The objective of the code is masking the image. To do so I created a mask, invert it and then use the function copyTo() to copy the pixels that are in white in the mask.

Code

capR >> frameR;
 
cvtColor(frameR, imGrayR, CV_RGB2GRAY);

cv::Mat mask2 = cv::Mat::zeros(frameR.size(), frameR.type());

cv::ellipse(mask2, cv::Point(650,700), cv::Size(300,400),
		180,0,180, cv::Scalar(255, 255, 255),-1,8,0);

cv::Mat inv_mask =  cv::Scalar::all(255) - mask2;

imGrayR.copyTo(masked_imGrayR, inv_mask);

imshow("masked image",masked_imGrayR);

waitKey(0);

Error

But while executing an error occur:
OpenCV Error: Assertion failed (mask.depth() == 0 && (mcn == 1 || mcn == cn)) in copyTo, file /home/roger/opencv/modules/core/src/copy.cpp, line 381
terminate called after throwing an instance of 'cv::Exception'
what(): /home/roger/opencv/modules/core/src/copy.cpp:381: error: (-215) mask.depth() == 0 && (mcn == 1 || mcn == cn) in function copyTo

Aborted (core dumped)

I have detected that the issue is in the line 6, in the function copyTo()
Can anyone help me with this issue??
Thank you

运行崩溃!!!!!!!

2019-11-22 09:12:12.387766+0800 Chapter15_DetectingFacialFeatures[13554:3631798] camera available: YES
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(4.1.2) /Volumes/build-storage/build/master_iOS-mac/opencv/modules/objdetect/src/cascadedetect.cpp:569: error: (-2:Unspecified error) in function 'bool cv::HaarEvaluator::Feature::read(const cv::FileNode &, const cv::Size &)'

Invalid HAAR feature (expected: 'rw.r.x + rw.r.width <= W'), where
'rw.r.x + rw.r.width' is 37
must be less than or equal to
'W' is 11

not compiling

faceAnimator = new FaceAnimator(parameters);

../Chapter15_DetectingFacialFeatures/Chapter15_DetectingFacialFeatures/ViewController.m:160:18: No viable overloaded '='

can't set faceAnimator

Chapter13_SavingVideo how to release memory after saving?

Hello, I have a question regarding the code on chapter 13. It works well the only issue I have is that memory usage keeps growing every time I record a new video…. How do you release memory, so the application does not crash… Thank you.

Chapter 7 - OpenCV error

I couldn't get Chapter 7 to work, so I downloaded the project here and got a similar error. re: "(-215)"
If useful, please look into for update. If not, and this is an error of my own, let me know and I'll close this. Not necessarily looking for someone to fix this for me - just relaying my user experience. Thanks! Unsigned int error, perhaps? I don't know much.

OpenCV Error: Assertion failed (mask.depth() == CV_8U && (mcn == 1 || mcn == cn)) in copyTo, file /Users/alexandershishkov/dev/opencv2.4.9/opencv/modules/core/src/copy.cpp, line 271
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/alexandershishkov/dev/opencv2.4.9/opencv/modules/core/src/copy.cpp:271: error: (-215) mask.depth() == CV_8U && (mcn == 1 || mcn == cn) in function copyTo

UIImageToMat,MatToUIImage methods

In the last version (3.2.0) these conversions methods(UIImageToMat,MatToUIImage) are in imgcodecs/ios.h. This class should be imported.
#import <opencv2/imgcodecs/ios.h>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.