~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/doc/tutorials/ios/hello/hello.markdown

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
OpenCV iOS Hello {#tutorial_hello}
 
2
================
 
3
 
 
4
Goal
 
5
----
 
6
 
 
7
In this tutorial we will learn how to:
 
8
 
 
9
-   Link OpenCV framework with Xcode
 
10
-   How to write simple Hello World application using OpenCV and Xcode.
 
11
 
 
12
Linking OpenCV iOS
 
13
------------------
 
14
 
 
15
Follow this step by step guide to link OpenCV to iOS.
 
16
 
 
17
-#  Create a new XCode project.
 
18
-#  Now we need to link *opencv2.framework* with Xcode. Select the project Navigator in the left
 
19
    hand panel and click on project name.
 
20
-#  Under the TARGETS click on Build Phases. Expand Link Binary With Libraries option.
 
21
-#  Click on Add others and go to directory where *opencv2.framework* is located and click open
 
22
-#  Now you can start writing your application.
 
23
 
 
24
![](images/linking_opencv_ios.png)
 
25
 
 
26
Hello OpenCV iOS Application
 
27
----------------------------
 
28
 
 
29
Now we will learn how to write a simple Hello World Application in Xcode using OpenCV.
 
30
 
 
31
-   Link your project with OpenCV as shown in previous section.
 
32
-   Open the file named *NameOfProject-Prefix.pch* ( replace NameOfProject with name of your
 
33
    project) and add the following lines of code.
 
34
    @code{.m}
 
35
    #ifdef __cplusplus
 
36
    #import <opencv2/opencv.hpp>
 
37
    #endif
 
38
    @endcode
 
39
    ![](images/header_directive.png)
 
40
 
 
41
-   Add the following lines of code to viewDidLoad method in ViewController.m.
 
42
    @code{.m}
 
43
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!" message:@"Welcome to OpenCV" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil];
 
44
    [alert show];
 
45
    @endcode
 
46
    ![](images/view_did_load.png)
 
47
 
 
48
-   You are good to run the project.
 
49
 
 
50
Output
 
51
------
 
52
 
 
53
![](images/output.png)
 
54
 
 
55
Changes for XCode5+ and iOS8+
 
56
-----------------------------
 
57
 
 
58
With the newer XCode and iOS versions you need to watch out for some specific details
 
59
 
 
60
-   The *.m file in your project should be renamed to *.mm.
 
61
-   You have to manually include AssetsLibrary.framework into your project, which is not done anymore by default.