"From the Zero Learning OpenCV" IOS7 under the OpenCV Development Start (xcode5.1.1&opencv2.49)

Source: Internet
Author: User

Preface:

Development IOS7 already have January of time, recently in preparing to push the research thing, a bit want to go to CV direction development, so began self-study OPENCV.

Attention to CSDN has been very long, but also from the very Dogbo master that learned a lot of knowledge, so I also from this week to start their own blog tour, from the beginning of zero to learn OpenCV, from the beginning to do notes to write blog, haha ~

Well, nonsense not much to say, to get to the point.


use OpenCV under IOS7

For MAC OS to use OPENCV of course to compile, but assuming that only the use of OpenCV under iOS, only need to import bulid good opencv2.framework into project can.

Opencv2.framework on the OPENCV official website can be downloaded, Portal:opencv2.framework


Below we create a new single View appliction under Xcode. Name is Cvforios.

Copy the downloaded opencv2.framework to the new project folder, and then import it into the project folder under Frameworks, and Libc++.dylib under IOS7.1, as well.


Then it needs to be in build settings. Set the C + + standard Library to libstdc++.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2hhd25fahq=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "width=" 614 "height=" >

Because the Min macro in OpenCV has a conflict with the Min macro of Uikit.

Therefore, you need to define the OPENCV header file in the. pch file, or there will be a compilation error.


Find cvforios-preix.pch changes such as the following:


At this point , the previous configuration work has been completed.


First case: Box filtering of photos on your phone with OPENCV

Because iOS generally uses the UIImage type to store the display image, to manipulate the image with OpenCV, you need to be able to freely convert between Cv::mat and UIImage.

Here we use the Open source code on GitHub, Portal :Aptogo

The code is as follows:

Note: the. mm file is a description of the mixed use of object-c and C + + two programming languages in this file, because OpenCV uses C + +, so be aware that only the OpenCV file must be replaced with the suffix. mm

All right. Then we finally get to the point where we first add a button, a Uiimageview control, and a uislider to the Main.storyboard. Layouts such as the following:

























The message responses and connections for each control are as follows:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2hhd25fahq=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "align=" left "width=" "height=" 292 ">













change the suffix name of the view controller implementation file to. mm. Let Viewcontroller implement uiimagepickercontrollerdelegate and uiactionsheetdelegate protocols

Detailed implementation code such as the following:

Header file:


implementation file:
Call Cv::boxfilter Implement the box filter, through the slider can adjust the size of the form, and finally the effect such as the following:

























Doge after the box filter is still so with sense. Dim eyes, haha!


Finally, the preparation of the work is done, and then you can use OPENCV on the phone to play ~

in the future, many other more interesting functions will be implemented with OPENCV on IOS7. Finally the entire case code is attached:Cvforios

(reprint please indicate author and source: Shawn-ht http://blog.csdn.net/shawn_ht do not use for commercial purposes without consent)


Article: http://blog.devtang.com/blog/2012/10/27/use-opencv-in-ios/

OpenCV Development from a zero-learning OpenCV IOS7 (xcode5.1.1&opencv2.49)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.