1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
/**
\page tutorial-getting-started-iOS Tutorial: How to create a basic iOS application that uses ViSP
\tableofcontents
\note We assume that you have `"ViSP for iOS"` either after following \ref tutorial-install-ios-package or \ref tutorial-install-iOS. Following one of these tutorials allows to exploit `visp3.framework` and `opencv2.framework` to build an application for iOS devices.
In this tutorial we suppose that you install `visp3.framework` in a folder named `<framework_dir>/ios`. If `<framework_dir>` corresponds to `$HOME/framework`, you should get the following:
\verbatim
$ ls $HOME/framework/ios
opencv2.framework visp3.framework
\endverbatim
Note also that all the material (source code and Xcode project) described in this tutorial is part of ViSP source code and could be downloaded using the following command:
\verbatim
$ svn export https://github.com/lagadic/visp.git/trunk/tutorial/ios/GettingStarted
\endverbatim
\section getting-started-iOS-create Create a new Xcode project
- Launch Xcode
- Follow `"File > New > Project"` menu and create a new iOS `"App"`
\image html img-getting-started-iOS-create.jpg
- Click on `"Next"` button and complete the options for your new project:
\image html img-getting-started-iOS-options.jpg
- Click on `"Next"` button and select the folder where the new project will be saved. Once done click on `"Create"`. Now you should have something similar to:
\image html img-getting-started-iOS-new.jpg
\section getting-started-iOS-link-visp Linking ViSP framework
Now we need to link `visp3.framework` with the Xcode project.
- Select the project navigator in the left hand panel (1) and click on project name `"Getting Started"` (2)
\image html img-getting-started-iOS-navigator.jpg
- Use the Finder to drag & drop ViSP and OpenCV frameworks located in `<framework_dir>/ios` folder in the left hand panel containing all the project files.
\image html img-getting-started-iOS-drag-drop.jpg
- In the dialog box, enable check box `"Copy item if needed"` to ease `visp3.framework` and `opencv2.framework` headers location addition to the build options
\image html img-getting-started-iOS-drag-drop-dialog.jpg
- Click on `"Finish"`. You should now get something similar to the following image
\image html img-getting-started-iOS-link-visp.jpg
\section getting-started-iOS-app Writing a ViSP iOS application
- Because we will mix Objective-C and ViSP C++ Code, rename `ViewController.m` file into `ViewController.mm`
\image html img-getting-started-iOS-rename.jpg
- Now copy/paste `$VISP_WS/visp/tutorial/ios/GettingStarted/GettingStarted/ViewController.mm` file content into `ViewController.mm`. Note that this Objective-C code is inspired from tutorial-homography-from-points.cpp.
\include GettingStarted/ViewController.mm
In this sample, we first import the headers to use vpHomography class. Then we create a new function called \c processViSPHomography(). This function is finally called in `viewDibLoad()`.
- After the previous copy/paste, you should have something similar to
\image html img-getting-started-iOS-code.jpg
- Now we are ready to build this simple `"Getting Started"` application using Xcode `"Product > Build"` menu.
\note Here it may be possible that you get a build issue \ref getting-started-ios-issue-libxml. Just follow the link to see how to fix this issue.
- You can now run your code using `"Product > Run"` menu (Simulator or device does not bother because we are just executing code). You should obtain these logs showing that visp code was correctly executed by your iOS project.
\image html img-getting-started-iOS-log.jpg
- if you don't see the output (1) presented in the red rectangle in the previous image, you may click on icon (2) to display `All Output`.
\section getting-started-ios-issues Known issues
\subsection getting-started-ios-issue-libxml iOS error: libxml/parser.h not found
If you encounter the following issue `iOS error: libxml/parser.h not found`
\image html img-getting-started-iOS-issue-libxml.jpg
the solution to this problem is to add libxml path. To this end, as shown in the next image:
\image html img-getting-started-iOS-issue-libxml-insert-path.jpg
- Select the project navigator in the left hand panel (1)
- Click on the project name (2)
- Click on the project name here also (3)
- Select `"Build Settings"` panel (4)
- Select `"All"` and `"Combined"` settings view (5)
- Enter `"header search"` in the search tool bar (6)
- In `"Header Search Paths"` press `+` button for `"Debug"` and `"Release"` configurations and add a new line (7):
\code
${SDK_ROOT}/usr/include/libxml2
\endcode
- Then clean and build again. Issue should be fixed.
\section getting-started-iOS-next Next tutorial
You are now ready to see the \ref tutorial-image-ios.
*/
|